我不能够把MEMO传上来我就简单的描述一下。随便画了个图。做出来就是这样的,看哪位高手能帮忙一下。我把图片 上传成附件了。想帮忙的请看一下,拜托了
下面是要求:
Basic Idea
Write a simple ATM-style program. The user types one or more names and amounts in the upper text area and then clicks on of the following three buttons: add a new account, deposit to an account or withdrawl from an account. The current accounts and their balances show up in the lower text area. To run a demo, type demo.hw3 in a lab machine terminal window.
--------------------------------------------------------------------------------
Specifications
The GUI must look exactly like the one in the demo. You must get explicit permission from me to modify it in any way.
The functionalities of the buttons are self explanatory. There is no upper or lower limit on individual account balances. (Other than the min and max values that a double can hold).
If the user tries to create accounts that already exist, then those accounts are not created again, and don't bother printing an error message. If the user tries to deposit to or withdrawl from accounts that don't exist, the amounts for those accounts are not modified and, as above, no error message is needed.
The input to the top text area must be in the following format:
<ws> Name <ws> : <ws> Amount <ws+>
<ws> = Zero or more whitespace characters (space, tab or newline)
<ws+> = One or more whitespace characters (space, tab or newline)
If the user's input is missing the : delimeter, then print an appropriate error message to the bottom of the window.
If the user's input has a messed-up value for the "amount", then print an appropriate error message to the bottom of the window.
--------------------------------------------------------------------------------
Program Structure
You are responsible for writing three classes:
ATMMain
This is the main class. It contains the main method, which simply creates an ATM and an ATMGUI. The whole thing should be about 4 lines long (minus comments).
ATMGUI
This is the class with the majority of the code in it. The constructor of this class should set up the window. ATMGUI should also implement ActionListener so that it can act as its own action handler.
In the actionPerformed method of this class, you should read in the user's input and parse it character-by-character into names and amounts. You may not use any of the fancy Java parsing tools. You can use only two methods in the String class: charAt() and length(). This part will require a lot of loops.
Once the input has been parsed and depending on which button has been pressed, you pass the name and amount on to the ATM to either create an account, deposit or withdrawl.
Finally, you print the updated contents of the ATM to the lower text area.
ATM
The ATM class is fairly simple. It acts as a "wrapper" for a TreeMap object in which you will store the actual accounts and balances. The ATM should have at least four methods:
newAccount(String, Double) - puts a new account into the TreeMap
deposit(String, Double) - deposits into an account in the TreeMap
withdrawl(String, Double) - withdrawls from an account in the TreeMap
getAccounts() - returns a String representation of all the accounts in the tree map. This is the String that will show up in the lower text area.
--------------------------------------------------------------------------------
Hints
Setting up the window is not difficult, but it does take a lot of code and, possibly, nitpicking. I will be giving out example code that should help simplify this process.
Parse one account from the input and then process it and then repeat for the next account in the input. In other words, Don't try to parse all the accounts at once, because this would require storing them somewhere until you are ready to send them to the ATM. You can do it however you want, but I think this is easier.
Constructing a String representation of the contents of the TreeMap isn't too difficult, but it does require a few tricky lines of code. Keep your eyes peeled for useful examples in class.
--------------------------------------------------------------------------------
Grading
10 - Code Style. Use Javadoc comments and make your code pretty or suffer the consequences!
15 - You made an obvious attempt to write something, even if it doesn't compile.
20 - The GUI looks exactly like the demo.
10 - The newAccount button works.
10 - The deposit button works.
10 - The withdrawl button works.
10 - Program is organized as described above.
15 - All input of the correct form is accepted and all input of the incorrect form is rejected. (with appropriate error messages)