File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Ready to give up! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Ready to give up!" Watch "Ready to give up!" New topic
Author

Ready to give up!

Stacey Johnson
Ranch Hand

Joined: Jan 11, 2004
Posts: 55
Hi,
I have had the same problem for a week right now and I don't seem to be getting the answer I need. I am a beginner in using Java, this is my first exposure to it and I'm taking a course which I am currently now in unit 8. A couple units ago I had to write a class named Account to model an account. I was given certain properites and methods to use. I also had to write a client program to test the account class. Below is both my Account class and client program all in one file.
Now two units later I am suppose to use the program and class I wrote and create two subclasses along with two separate test programs to test the subclasses. The two subclasses are savings and chequing account. The savings account which I'm currently working on is suppose to show "Insufficient" funds when someone tries to withdraw too much. As you can see my Account class and testAccountClass program doesn't accept user input. But in my testSavingsClass program can I not have user input without changing my original program and class? I've had people help me by trying to re-write my testaccountclass code to include savings account all in one. I can't do that as my testAccountClass is one assignment that has to be marked separate from my current. I need help with the code, I have no idea how to go about it. I haven't really started on my TestSavingsAccount test program yet because I don't know if I'm even doing my SavingsAccount subclass correct. Can someone please help me I'm ready to give up I just don't know what to do.
Below are the code I have so far, starting with my TestAccountClass which is working fine.

And here is the start of my SavingsAccount subclass code (not the test program):

Please help
Stacey
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
In your TestSavingsAccount file, you may want to pass in a value that comes from user input rather than a hard coded number like you used in TestAccountClass. You don't need to change Account or SavingsAccount to do that. On the other hand, you should realize that you can call a method more than once. So you could withdraw(10), do a System.out.println(result), then withdraw(100), do another print, ... continue to withdraw until you get the message you want.

However, your SavingsAccount class should have a little additional functionality (like having the withdraw() method return "Insufficient" when appropriate. You probably want to have the same methods as the Account class only with slightly different functionality.
[ February 27, 2004: Message edited by: Marilyn de Queiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Stacey Johnson
Ranch Hand

Joined: Jan 11, 2004
Posts: 55
Hi,
Thanks for your reply. One question I have is how is my SavingsAccount subclass looking I'm not too sure if I'm on the right track with it. I will start working on my SavingsAccountTest program and go from there. My one question is how do I pass a user input value rather than a hard code value in my SavingsAccountTest. My text didn't really show any examples of user input when doing things this way so I don't have anything to use for a guidline.
Thanks so much for your help I appreciate it. Maybe I won't go insane afterall.
Stacey
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I'm not sure I've understood everything.
In a recent post, indicated that you figured out how to get user input. (I'd guess with a JOptionPane.showInputDialog() invocation.) But then you went on to say that you didn't want to change your test application to use the input values, since your test application was working as it was.
From this post, I'll guess that you do want to change your test application to use some user input values, and that you'd perhaps like to see a simple example of doing such a thing. So, here goes...

[ February 28, 2004: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Ready to give up!
 
Similar Threads
Objects and Classes
SubClass Blues!
Very Confused!!
Help on testprogram and subclass please
Having trouble understanding an error code i keep getting. Please help!