Results 1 to 2 of 2
Thread: command help
- 12-04-2007, 06:04 PM #1
Member
- Join Date
- Nov 2007
- Posts
- 38
- Rep Power
- 0
- 12-05-2007, 12:24 AM #2
Java Code:public class CashierTest { public static void main(String[] args) { InputReader reader = new InputReader(); Cashier cashier = new Cashier(); cashier.generateResponse(Cashier.CREATE, reader); cashier.generateResponse(Cashier.DEPOSIT, reader); } } class Cashier { HashMap<String, Account> accounts; final static String CREATE = "create"; final static String DEPOSIT = "deposit"; public Cashier() { accounts = new HashMap<String, Account>(); } public void generateResponse(String word, InputReader reader) { if(word.equals(CREATE)) { createAccount(reader); } if(word.equals(DEPOSIT)) { makeDeposit(reader); } } private void createAccount(InputReader reader) { String email = reader.getText("enter email address: "); String password = reader.getText("enter password: "); if(accounts.containsKey(email)) { System.out.println("The account already exists"); } else { Account account = new Account(email, password); accounts.put(email, account); System.out.println("Your account has been created"); } } private void makeDeposit(InputReader reader) { String email = reader.getText("enter email address: "); String password = reader.getText("enter password: "); int amount = reader.getNumber("enter deposit amount: "); if(accounts.containsKey(email)) { Account account = (Account)accounts.get(email); if(account.getPassword().equals(password)) { boolean success = account.deposit(amount); if(success) System.out.println("Thank you for using the bank"); else System.out.println("Unable to deposit to your account"); } } } }
Similar Threads
-
command
By dirtycash in forum New To JavaReplies: 8Last Post: 01-02-2008, 07:52 PM -
Exporting from the command line
By o1121 in forum EclipseReplies: 1Last Post: 08-09-2007, 07:29 PM -
Eclipse underliying command
By o1121 in forum EclipseReplies: 2Last Post: 08-08-2007, 07:27 AM -
Unable to execute command line command in java
By LordSM in forum New To JavaReplies: 1Last Post: 08-08-2007, 12:23 AM -
problems with jar command
By simon in forum Advanced JavaReplies: 1Last Post: 07-13-2007, 04:21 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks