• Post Reply Bookmark Topic Watch Topic
  • New Topic

Asking for help! Dont understand this code  RSS feed

 
asterix obelix
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.");

}
}
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"asterix obelix",
Please check your private messages.
-DOM
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you see any return statements? Where is the insertMoney method? Do you know what a return statement is? Have a look at the following in Sun's Java Tutorials: Returning a Value from a Method
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!