• Post Reply Bookmark Topic Watch Topic
  • New Topic

How would I call an integer in one method to another?  RSS feed

 
David Vach
Ranch Hand
Posts: 105
3
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, so what I am trying to do it take the Value that I am allowing my BargainCustomer to spend, and get him/her to buy the first car they see in the list under that price. Then take the remaining money and buy whatever features they can. However, I do not remember how to call my value for the remaining money from my other method. Here is my code:


Ideally the buyer should only buy what they can afford with the remaining money.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are declaring the amount 35000 inside the method; it therefore only exists inside that method and cannot be found elsewhere. I think you want it to be a field, in which case you might do well to initialise it via a constructor.
Before you go any further, please turn your computer off and draw a diagram representing the execution of your program. You may only need a row of cars with prices. I think you will find it does something different from what you think.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!