posted 15 years ago
I really dont understand this code. Could someone please answer my questions? Thank you very much.
1. Do the insertMoney and printTicket methods have return statements?
2. Why do you think this might be?
3. Do you notice anything about their headers that might suggest why they do not require return statements
The code
----------
public int getPrice()
{
return price;
}
/**
public void printTicket()
{
if(balance >= price) {
// Simulate the printing of a ticket.
System.out.println("##################");
System.out.println("# The BlueJ Line");
System.out.println("# Ticket");
System.out.println("# " + price + " cents.");
System.out.println("##################");
System.out.println();
// Update the total collected with the price.
total = total + price;
// Reduce the balance by the prince.
balance = balance - price;
}
else {
System.out.println("You must insert at least: " +
(price - balance) + " more cents.");
}
}