• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting input from the User

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to write an application which resembles a users bank account. So to start the app I need the user to enter how much they would like to open the account with.
I am using the JOptionPane to create a dialog box where the user enters the amount. I am setting this as "input" os my code looks like this:
String input
input = JOptionPane.showDialogBox("How much would you like to open you account with");
Now the problem I am having and the question I have is how can I store this info in another class. I have created another class that defines what an Account is, I want to pass this information to that class so I can use it in the methods of that class.
Do I create a new object of the Account and call the methods from that object and pass the value of "input", all within the same class where I have my Dialog box or can do I call that "getBalance" accessor method that I have created in the Account class, in on of my Account counstructor methods, and when I go to create a Account object I pass the value of "input" then?
Does this make sense?
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the class where you get the input from the user, you should also have a getInput() method that the Account class can call to get the value that the user entered.

I think that getBalance() should be used for something else, namely getting the current balance of the account.
[ May 29, 2003: Message edited by: Marilyn de Queiroz ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic