• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trouble with setting methods and how they work.  RSS feed

 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm doing a problem where I'm supposed to create a class that sets methods for invoice number, amount of sale, and sales taxed (subsumed under the method for amount of sale). Basically, the problem is to use a loop for the main method when the user inputs the invoice number and sale amount, resulting in showing the invoice number and amount so long as they don't input a number outside of the parameters.

The class compiles fine and is similar to other problems I've done that worked fine. But, when I try to compile the main method I keep getting an error for "amount." I'm not sure why this is and the only thing I can think of is I have to declare it up top in the class, but then I don't understand why "invoice" compiles with no problem. Can someone please explain what I'm not understanding? Thanks for any tips/advice.

Here's the class:



Here's the main:



And the error I get is:

 
Charles D. Ward
Ranch Hand
Posts: 99
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error is telling you exactly what's wrong.

You don't have a variable named amount in your CreatePurchase class, but you have a variable named saleAmount.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!