Hello folks, I am a beginner struggling to code and after much struggle I have created a checking and saving account and the purpose of this program is to dispaly the balance amount in each account after an user enters an amount to deposit or withdraw from a text box and it should also display an "overdraft message" when the balance in either accounts go red (below zero). I have gotten thus with the following piece of code.
You have made two instances of your Account class, one for checking and one for savings. But in the Account class you draw the same balance twice with both "checking" and "savings" descriptions. Each Account instance only knows one account, so it should only display one balance.
Now, how would an Account instance know what description to print? It should either say "checking" or "savings". Look for a way to tell the Account which one it is so it can display the description later.
I've never done drawing on graphics like that. The way you called checking.display(g) and savings.display(g) ... does that display one after the other or does one replace the other on screen?
Let me know if that helps! And look into the CODE button below the editor when you post code. That helps preserve your indentation and makes things easier for all to read.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Stan, Thank you. I figured what i was doing wrong, so i created two seperate variables for storing the balances from checking and saving account and displayed it in the paint method.
But i am supposed to use the method display in the Account class and call it up at the paint method. I thought of putting the code inside display() instead of paint method but i realized it won't work because it will not recognize the variables check and save and so i am flustered now. My program works fine but i should use the display method and call it up at paint method which i am stuck at now. Help appreciated, Kanaka
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart: