| Author |
Any ideas about errors
|
ezekiel diligene
Greenhorn
Joined: Dec 01, 2005
Posts: 5
|
|
class CarPark1 { // private instance variables private int Payment, total, balance; // public no-argument constructor public CarPark1() { } // public constructor with three arguments public CarPark1(int p, int t, int b) { payment = p; total = t; balance = b; } // public 'set' methods public void setPayment(int p) { payment = p; } public void setTotal(int total) { total = t; } public void setbalance(int balance) { balance = b; } // public method to calculate the total public int calculateTotal() { int balance = total - payment; // more code here to show balance =>0 message displayed return balance; } } Any advice would be much appreciated. I'm fairly new at this....
|
b.notes
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9956
|
|
help us help you. what exact errors are you getting? what are you expecting to see? also, if you'd use the code tags, it'd preserve your formatting, and make your code easier to read. use those "instant UBB" buttons to get the tags, then paste your formatted code between them.
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
Greg Charles
Bartender
Joined: Oct 01, 2001
Posts: 2542
|
|
|
One problem is you declare an instance variable as Payment, then use it as payment. Java variables are case sensitive, and by convention should always start with a lowercase letter.
|
 |
Srinivas Kumar
Ranch Hand
Joined: Jul 14, 2005
Posts: 52
|
|
Also u haven't declared the variable t in the method setTotal(). Same is the case with the variable b in setbalance() method.
|
 |
ezekiel diligene
Greenhorn
Joined: Dec 01, 2005
Posts: 5
|
|
|
thanks so much for all your assistance .. I'll be back to let you knoew the results Cheers Guys...
|
 |
 |
|
|
subject: Any ideas about errors
|
|
|