package proj1;
import java.util.Scanner;
public class Project1{
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String selection = "";
String registerState = "";
int register = 0;
int registerTransfer = 0;
int registerLocked = 0;
int registerUnlock = 0;
Scanner scan = new Scanner(System.in);
System.out.println("Enter the amount of ones: ");
int ones = scan.nextInt();
System.out.println("Enter the amount of fives: ");
int fives = scan.nextInt();
System.out.println("Enter the amount of tens: ");
int tens = scan.nextInt();
System.out.println("Enter the amount of twenties: ");
int twenties = scan.nextInt();
CashRegister cr1 = new CashRegister(ones, fives, tens, twenties);
CashRegister cr2 = new CashRegister(ones, fives, tens ,twenties);
System.out.println("What would you like to do:");
do
{
System.out.println("A - Add money");
System.out.println("R - Remove money");
System.out.println("T - Transfer money");
System.out.println("L - Lock register");
System.out.println("U - Unlock register");
System.out.println("S - Display register state");
System.out.println("C - Close store and quit");
selection = scan.next();
cr1.addMoney(ones, fives, tens, twenties);
if( selection.equalsIgnoreCase("A"))
{
System.out.println("Which Cash Register do you want to add to (1,2)");
register = scan.nextInt();
System.out.println("How many ones do you want to add?");
ones = scan.nextInt();
System.out.println("How many fives do you want to add?");
fives = scan.nextInt();
System.out.println("How many tens do you want to add?");
tens = scan.nextInt();
System.out.println("How many twenties do you want to add?");
twenties = scan.nextInt();
if(register == 1)
{
cr1.addMoney(ones, fives, tens, twenties);
}
else if (register == 2)
{
cr2.addMoney(ones, fives, tens, twenties);
}
else
{
throw new RuntimeException("Choose either register one or two");
}
}//ends selection A
if(selection.equalsIgnoreCase("R"))
{
System.out.println("Which Cash Register do you want to subtract from (1,2)");
register = scan.nextInt();
System.out.println("How many ones do you want to remove?");
ones = scan.nextInt();
System.out.println("How many fives do you want to remove?");
fives = scan.nextInt();
System.out.println("How many tens do you want to remove?");
tens = scan.nextInt();
System.out.println("How many twenties do you want to remove?");
twenties = scan.nextInt();
if(register == 1)
{
cr1.removeMoney(ones, fives, tens, twenties);
}
else if (register == 2)
{
cr2.removeMoney(ones, fives, tens, twenties);
}
else
{
throw new RuntimeException("Choose either register one or two");
}
}
if(selection.equalsIgnoreCase("T"))
{
System.out.println("Which register do you want to transfer money from (1,2)");
registerTransfer = scan.nextInt();
System.out.println("Enter the amount of ones:");
ones = scan.nextInt();
System.out.println("Enter the amount of fives:");
fives = scan.nextInt();
System.out.println("Enter the amount of tens:");
tens = scan.nextInt();
System.out.println("Enter the amount of twenties:");
twenties = scan.nextInt();
if(registerTransfer == 1)
{
cr1.removeMoney(ones, fives, tens, twenties);
cr2.addMoney(ones, fives, tens, twenties);
}
else if(registerTransfer == 2)
{
cr2.removeMoney(ones, fives, tens, twenties);
cr1.addMoney(ones, fives, tens, twenties);
}
else
{
throw new RuntimeException("Choose either register one or two");
}
}//ends selection T
if(selection.equalsIgnoreCase("L"))
{
System.out.println("Which register do you want to lock (1,2)");
registerLocked = scan.nextInt();
if(registerLocked == 1)
{
cr1.lock();
}
else if(registerLocked == 2)
{
cr2.lock();
}
else
{
throw new RuntimeException("Choose either register one or two");
}
}//ends selection L
if(selection.equalsIgnoreCase("U"))
{
System.out.println("Which register do you want to unlock (1,2)");
registerUnlock = scan.nextInt();
if(registerUnlock == 1)
{
cr1.unlock();
}
else if (registerUnlock == 2)
{
cr2.unlock();
}
else
{
throw new RuntimeException("Choose either register one or two");
}
}//ends selection U
if(selection.equalsIgnoreCase("S"))
{
System.out.println(cr1.toString());
registerState= scan.next();
System.out.println(cr2.toString());
registerState= scan.nextLine();
}//ends selection S
else if(selection.equalsIgnoreCase("C"))
{
cr1.lock();
cr2.lock();
cr1.CashReg(0, 0, 0, 0);
cr2.CashReg(0, 0, 0, 0);
System.out.println("The store is closed:\n"+ cr1.toString());
}//ends selection C
} while(!selection.equalsIgnoreCase("C"));
}
}