A Command Loop

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]

TestBankAccount.java
public static void main(String args[]) {
   BankAccount account;   // the bank account we are testing
   int amountAsInt;       // amount parameter as int
   double amountAsDouble; // amount parameter as double
   String command;        // command line
   char cmdletter;        // first character of the command

   account = new BankAccount();

   // Process commands from the input

   do {
      command = RitIo.getString("Your command: ");
      cmdletter = command.charAt(0);

      switch (cmdletter) {
      // ...
      }
   } while (cmdletter != 'x');
}

*This little test program allows to access all methods of the BankAccount class by using one-letter commands.
 

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]
Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 11, 2002