void mainMenu () {
    CinReader reader;
    while (true) {
        cout << "MAIN MENU\n" << endl;
        cout << "[1] Box    -- interactive test" << endl;
        cout << "[2] Prize  -- interactive test" << endl;
        cout << "[3] Run official unit test" << endl;
        cout << "[0] Quit" << endl;
        cout << "Your choice: ";
        
        switch (reader.readInt(0,3)) {
            case 0:
                exit(1);
                break;
            case 1:
                boxMenu();
                break;
            case 2:
                prizeMenu();
                break;
            case 3:
                unittest();
                pause ();
                break;
        }
    }
}
Esempio n. 2
0
void setupItem (int number, string& todoItem)
{
    cout << "Enter todo item #" << number << " (hit enter to skip): ";
    string input = reader.readString();
    if (input.length() > 0)
        todoItem = input;
}
Esempio n. 3
0
void setupDay(day& anyDay)
{
    system ("cls");
    cout << "You are setting up: " << anyDay.name << "\n\n";

    cout << "Type a note/journal entry (just hit enter to skip): ";
    string input = reader.readString();
    if (input.length() > 0)
        anyDay.note = input;

    setupItem(1, anyDay.todo1);
    setupItem(2, anyDay.todo2);
    setupItem(3, anyDay.todo3);
    setupItem(4, anyDay.todo4);
    setupItem(5, anyDay.todo5);
    cout << "Hit enter to continue";
    reader.readString();

}
int main (int argc, char* argv[]) {
    CinReader mainReader;
    unsigned int menuChoice = 0;
	
    // CODE HERE -- INTERACTIVE TEST
    //
    // add additional functions as needed to support interactive test
	do {
		clearScreen();
		//menu here
		cout << "MAIN MENU\n\n";
        cout << "[1] Unit Test\n";
	    cout << "[2] Prize Test\n";
	    cout << "[3] Box Test\n";
	    cout << "[0] Exit program\n";
	    cout << "Your choice: ";
		// read in menu choice here
        menuChoice = mainReader.readInt(true,0,3);
		clearScreen();
		
		// menu switch goes here
		switch(menuChoice){
		    case 1:
		      unittest();
		     break;
		    case 2:
		      prizeTest();
		      //Prize Test here
		     break;
		    case 3:
		      boxTest();
		      //Box Test here
		     break;
		}
		
		if (menuChoice > 0) {
			cout << endl << "Press ENTER to continue";
			mainReader.readString();
		}
	} while (menuChoice != 0);
	
    return 0;
}
Esempio n. 5
0
int atm()
{
    CinReader reader;
    BankAccount myBanking;
    bool end_program = false;
    bool done = false;
    long dollars;
    int cents;
    do
    {
        cout << "Select the type of account you wish to create" << endl;
        cout << "1 Bank Account 2 - Checking 3 - Savings 4 - Credit\n" << endl;
        int choice = reader.readInt(1,4);
        string account_name;
        long balance_dollars;
        int balance_cents;
        double interest_rate;
        switch(choice)
        { 
            //Bank account options
            case 1:
            {
                cout << "Set the dollar amount of your account balance\n" << endl;
                balance_dollars = reader.readInt(0);
                cout << "Set the cent amount of your account balance\n" << endl;
                balance_cents = reader.readInt(0,99);
                myBanking.SetDollars(balance_dollars);
                myBanking.SetCents(balance_cents);
                cout << "Please select from the following options." << endl;
                while(!done)
                {
                    cout << "1 - Show account balance\n2 - Deposit\n3 - Withdraw\n4 - Show recent transactions\n5 - Clear Transaction history\n6 - Exit ATM\n" << endl;
                    int choice = reader.readInt(1,6);
                    switch(choice)
                    {
                        case 1:
                        {
                            cout << myBanking.ShowBalance() << endl;
                        break;
                        }
                        
                        case 2:
                        {
                            cout << "Please enter the amount in dollars you would like to deposit, followed by the amount in cents\n" << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            myBanking.DepositAccount(dollars, cents);
                        break;
                        }
                        
                        case 3:
                        {
                            cout << "Please enter the amount in dollars you would like to withdraw, followed by the amount in cents\n" << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            myBanking.WithdrawAccount(dollars, cents);
                        break;
                        }
                        
                        case 4:
                        {
                            for(int i = 0;i<10;i++)
                            {
                                if(myBanking.GetRecentTransactions(i) == "")
                                {
                                    cout << "none" << endl;
                                }else
                                {
                                cout << myBanking.GetRecentTransactions(i) << endl;
                                }
                            }
                            
                            cout << "Your last transaction was: " << myBanking.GetLastTransaction() << endl;
                        break;
                        }
                        
                        case 5:
                        {
                            myBanking.ClearRecentTransactions();
                        break;
                        }
                        
                        case 6:
                        {
                            done = true;
                        }
                    }
                }
            break;
            }
            
            //Checking account options
            case 2:
            {
                CheckingAccount myChecking;
                cout << "Set the dollar amount of your account balance" << endl;
                balance_dollars = reader.readInt(0);
                cout << "Set the cent amount of your account balance\n" << endl;
                balance_cents = reader.readInt(0,99);
                myChecking.SetDollars(balance_dollars);
                myChecking.SetCents(balance_cents);
                cout << "Please select from the following options." << endl;
                
                while(!done)
                {
                    cout << "1 - Show account balance\n2 - Deposit Money/Check\n3 - Withdraw/Write a check\n4 - Show recent transactions\n5 - Clear Transaction history\n6 - Exit ATM\n" << endl;
                    int choice = reader.readInt(1,6);
                    switch(choice)
                    {
                        case 1:
                        {
                            cout << myChecking.ShowBalance() << endl;
                        break;
                        }
                        
                        case 2:
                        {
                            cout << "Would you like to deposit money into your account or cash a check?" << endl;
                            cout << "Press 1 to deposit money and 2 to cash a check" << endl;
                            int choice = reader.readInt(1,2);
                            if(choice == 1)
                            {
                                cout << "Please enter the amount in dollars you would like to deposit, followed by the amount in cents\n" << endl;
                                dollars = reader.readInt(0);
                                cents = reader.readInt(0,99);
                                myChecking.DepositAccount(dollars, cents);
                            } else 
                            {
                                cout << "Please enter the dollar value of the check you are cashing, followed by the cent value" << endl;
                                dollars = reader.readInt(0);
                                cents = reader.readInt(0,99);
                                cout << "Please enter the amount you'd like to keep in dollars, followed by cents\n" << endl;
                                long kept_dollars = reader.readInt(0);
                                int kept_cents = reader.readInt(0,99);
                                myChecking.CashCheck(dollars, cents, kept_dollars, kept_cents);
                            }
                        break;
                        }
                        
                        case 3:
                        {
                            cout << "Please enter the check number that you are writing" << endl;
                            int check_number = reader.readInt(0);
                            cout << "Please enter the amount the check is for in dollars, followed by the amount in cents\n" << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            myChecking.WriteCheck(check_number, dollars, cents);
                        break;
                        }
                        
                        case 4:
                        {
                            for(int i = 0;i<10;i++)
                            {
                                if(myChecking.GetRecentTransactions(i) == "")
                                {
                                    cout << "none" << endl;
                                }else
                                {
                                cout << myChecking.GetRecentTransactions(i) << endl;
                                }
                            }
                            
                        break;
                        }
                        
                        case 5:
                        {
                            myChecking.ClearRecentTransactions();
                        break;
                        }
                        case 6:
                        {
                            done = true;
                        }
                    }
                }
            break;
            }
            
            //Savings account options
            case 3:
            {
                SavingAccount mySavings;
                cout << "Set the dollar amount of your account balance" << endl;
                balance_dollars = reader.readInt(0);
                cout << "Set the cent amount of your account balance" << endl;
                balance_cents = reader.readInt(0,99);
                cout << "Select your interest rate\n" << endl;
                interest_rate = reader.readDouble();
                mySavings.SetDollars(balance_dollars);
                mySavings.SetCents(balance_cents);
                mySavings.SetInterestRate(interest_rate);
                cout << "Please select from the following options." << endl;
                while(!done)
                {
                    cout << "1 - Show account balance\n2 - Deposit\n3 - Withdraw\n4 - Show recent transactions\n5 - Clear Transaction history\n6 - Calculate Interest\n7 - Show interest accumulated\n8 - Exit ATM\n" << endl;
                    int choice = reader.readInt(1,8);
                    switch(choice)
                    {
                        case 1:
                        {
                            cout << mySavings.ShowBalance() << endl;
                        break;
                        }
                        
                        case 2:
                        {
                            cout << "Please enter the amount in dollars you would like to deposit, followed by the amount in cents\n" << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            mySavings.DepositAccount(dollars, cents);
                        break;
                        }
                        
                        case 3:
                        {
                            cout << "Please enter the amount in dollars you would like to withdraw, followed by the amount in cents\n" << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            mySavings.WithdrawAccount(dollars, cents);
                        break;
                        }
                        
                        case 4:
                        {
                            for(int i = 0;i<10;i++)
                            {
                                if(mySavings.GetRecentTransactions(i) == "")
                                {
                                    cout << "none" << endl;
                                }else
                                {
                                cout << mySavings.GetRecentTransactions(i) << endl;
                                }
                            }
                            
                        break;
                        }
                        
                        case 5:
                        {
                            mySavings.ClearRecentTransactions();
                        break;
                        }
                        
                        case 6:
                        {
                            mySavings.CalculateInterest();
                        break;
                        }
                        
                        case 7:
                        {
                            cout << "Interest accumulated this month: " << mySavings.GetInterestAccumulatedMonth() << endl;
                            cout << "Interest accumulated this year: " << mySavings.GetInterestAccumulatedYear() << "\n" << endl;
                        break;
                        }
                        
                        case 8:
                        {
                            done = true;
                        }
                    }
                }
            break;
            }
            
            //Credit Account options
            case 4:
            {
                CreditAccount myCredit;
                cout << "Set the dollar amount of your account balance" << endl;
                balance_dollars = reader.readInt(0);
                cout << "Set the cent amount of your account balance" << endl;
                balance_cents = reader.readInt(0,99);
                cout << "Select your interest rate. NOTE: Must be greater or equal to 0.0" << endl;
                interest_rate = reader.readDouble();
                cout << "Set the dollar amount for your max balance" << endl;
                long max_dollars = reader.readInt(0);
                cout << "Set the cent amount for your max balance\n" << endl;
                int max_cents = reader.readInt(0, 99);
                myCredit.SetDollars(balance_dollars);
                myCredit.SetCents(balance_cents);
                myCredit.SetMaxBalanceDollars(max_dollars);
                myCredit.SetMaxBalanceCents(max_cents);
                myCredit.SetInterestRate(interest_rate);
                
                cout << "Please select from the following options." << endl;
                while(!done)
                {
                    cout << "1 - Show account balance\n2 - Deposit\n3 - Withdraw\n4 - Calculate Interest\n5 - Clear Transaction history\n6 - Calculate interest\n7 - Show interest accumulated\n8 - Exit ATM\n" << endl;
                    int choice = reader.readInt(1,8);
                    switch(choice)
                    {
                        case 1:
                        {
                            cout << myCredit.ShowBalance() << endl;
                        break;
                        }
                        
                        case 2:
                        {
                            cout << "Please enter the amount you would like pay towards your balance in dollars, followed by cents\n" << endl << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            myCredit.MakePayment(dollars, cents);
                        break;
                        }
                        
                        case 3:
                        {
                            cout << "Please enter the transaction number for the charge" << endl;
                            int transaction = reader.readInt(0);
                            cout << "Please enter the amount of the transaction in dollars, followed by cents\n" << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            myCredit.ChargeCard(transaction, dollars, cents);
                        break;
                        }
                        
                        case 4:
                        {
                            for(int i = 0;i<10;i++)
                            {
                                if(myCredit.GetRecentTransactions(i) == "")
                                {
                                    cout << "none" << endl;
                                }else
                                {
                                cout << myCredit.GetRecentTransactions(i) << endl;
                                }
                            }
                            
                        break;
                        }
                        
                        case 5:
                        {
                            myCredit.ClearRecentTransactions();
                        break;
                        }
                        
                        case 6:
                        {
                            myCredit.CalculateInterest();
                        break;
                        }
                        
                        case 7:
                        {
                            cout << "Interest accumulated this month: " << myCredit.GetInterestAccumulatedMonth() << endl;
                            cout << "Interest accumulated this year: " << myCredit.GetInterestAccumulatedYear() << "\n" << endl;
                        break;
                        }
                        
                        
                        case 8:
                        {
                            done = true;
                        }
                    }
                }
            }//break
        }
    }while(!end_program);
}
void boxMenu () {
    Box box1;
    CinReader reader;
    string newName = "";
    unsigned int newValue = 0;
    unsigned int prizeRemove = 0;
    
    while (true) {
        system("clear");
        cout << "BOX TEST\n" << endl;
        cout << "Box info -> " << box1.getBoxNumber() << ", " << box1.getBoxColor() << endl;
        cout << "[1] Add prize" << endl;
        cout << "[2] View prizes" << endl;
        cout << "[3] Remove prize" << endl;
        cout << "[4] Change Box number" << endl;
        cout << "[5] Change Box color" << endl;
        cout << "[6] View prize capacity" << endl;
        cout << "[7] View prize count" << endl;
        cout << "[0] Back to main menu" << endl;
        cout << "Your choice: ";
        
        switch (reader.readInt(0,7)) {
            case 0:
                system("clear");
                box1.~Box();
                mainMenu ();
                break;
            case 1:
                system("clear");
                cout << "New prize name (current = NO NAME): ";
                    newName = reader.readString();
                cout << "New prize value (current = 0): ";
                    newValue = reader.readInt();
                    
                if (box1.getPrizeCount() < box1.getPrizeCapacity()) {
                    box1.addPrize(Prize (newName, newValue));
                } else {
                    cout << "Your prize could not be added." << endl;
                }
                
                pause ();
                break;
            case 2:
                system("clear");
                
                if (box1.getPrizeCount() == 0){
                    cout << '\n';
                } else {
                   for (unsigned int i = 0; i < box1.getPrizeCount(); i++) {
                       cout << i + 1 << ": " << box1.getPrize(i).getPrizeName() << endl;
                   } 
                }
                
                pause ();
                break;
            case 3:
                system("clear");
                
                if (box1.getPrizeCount() == 0){
                    cout << '\n';
                } else {
                   for (unsigned int i = 0; i < box1.getPrizeCount(); i++) {
                       cout << i + 1 << ": " << box1.getPrize(i).getPrizeName() << endl;
                   } 
                }
                
                cout << "Remove which prize (0 to cancel)? ";
                    prizeRemove = reader.readInt(0, box1.getPrizeCount());
                
                    if (prizeRemove == 0) {
                        system("clear");
                    } else {
                        box1.removePrize(prizeRemove - 1);
                        cout << "Prize number " << prizeRemove << " removed." << endl;
                    }
                    pause ();
                    break;
            case 4:
                system("clear");
                cout << "Current number is: " << box1.getBoxNumber() << endl;
                cout << "\nEnter in a new number: ";
                    box1.setBoxNumber(reader.readInt());
                cout << "\nNew box number is: " << box1.getBoxNumber() << endl;
                pause ();
                break;
            case 5:
                system("clear");
                cout << "Current color is: " << box1.getBoxColor() << endl;
                cout << "\nEnter in a new color: ";
                    box1.setBoxColor(reader.readString());
                cout << "\nNew box color is: " << box1.getBoxColor() << endl;
                pause ();
                break;
            case 6:
                system("clear");
                cout << "Current prize capacity: " << box1.getPrizeCapacity() << endl;
                pause ();
                break;
            case 7:
                system("clear");
                cout << "Current prize count: " << box1.getPrizeCount() << endl;
                pause ();
                break;
        }
    }
}
void prizeMenu () {
    Prize prize1;
    Prize prize2;
    CinReader reader;
    string p1Name;
    unsigned int p1Value = 0;
    string p2Name;
    unsigned int p2Value = 0;
    
    while (true) {
        system("clear");
        cout << "PRIZE TEST\n" << endl;
        cout << "Prize info -> " << prize1.getPrizeName() << ", $" << prize1.getPrizeValue() << endl;
        cout << "[1] Prize name" << endl;
        cout << "[2] Prize value" << endl;
        cout << "[3] Compare two prizes" << endl;
        cout << "[0] Back to main menu" << endl;
        cout << "Your choice: ";
        
        switch (reader.readInt(0,3)) {
            case 0:
                system("clear");
                prize1.~Prize();
                mainMenu ();
                break;
            case 1:
                system("clear");
                cout << "Prize name: " << prize1.getPrizeName() << endl;
                cout << "\nUpdate (y/n)? ";
                
                if (reader.readChar("yn") == 'y') {
                    cout << "\nEnter new prize name: ";
                        prize1.setPrizeName(reader.readString());
                    cout << "\nPrize name updated." << endl;
                }
                
                pause ();
                break;
            case 2:
                system("clear");
                cout << "Prize value: " << prize1.getPrizeValue() << endl;
                cout << "\nUpdate (y/n)? ";
                
                if (reader.readChar("yn") == 'y') {
                    cout << "\nEnter new prize value: ";
                        prize1.setPrizeValue(reader.readInt());
                    cout << "\nPrize value updated." << endl;
                }
                
                pause ();
                break;
            case 3:
                system("clear");
                cout << "First, set the Name and Value of the prizes being compared.\n" << endl;
                cout << "Prize 1 ->" << endl;
                cout << "Prize name (current = NO NAME): ";
                    p1Name = reader.readString();
                cout << "Prize value (current = 0): ";
                    p1Value = reader.readInt();
                cout << "\nPrize 2 ->" << endl;
                cout << "Prize name (current = NO NAME): ";
                    p2Name = reader.readString();
                cout << "Prize value (current = 0): ";
                    p2Value = reader.readInt();
                  
                Prize prize1(p1Name, p1Value); 
                Prize prize2(p2Name, p2Value);
                if (prize1 == prize2) {
                    cout << "Yes. The two prizes are the same." << endl;
                } else {
                    cout << "No. The two prizes are not the same." << endl;
                }
            
                pause ();
                break;
        }
    }
}
Esempio n. 8
0
void menu() {
    
    //set up the default prize and box
    Prize prize1;
    Box box1;
    
    //set up the custom prize and box
    string pName;
    unsigned int pValue = 0;
    cout << "Please enter values for the Custom Prize\n"
         << "Name: ";
    pName = reader.readString(false);
    cout << "Value: ";
    pValue = reader.readInt(0);
    Prize prize2(pName, pValue);
    
    unsigned int bNum = 0, bPrizeCap = 0;
    string bColor;
    cout << "Please enter Stats for the Custom Box\n"
         << "Number: ";
    bNum = reader.readInt(0);
    cout << "Color: ";
    bColor = reader.readString(false);
    cout << "Prize Capacity: ";
    bPrizeCap = reader.readInt(0);
    Box box2(bNum, bColor, bPrizeCap);
    clearScreen();
    
    //variable to hold the user's choice from the menu
    char user_choice;
    
    //bool for looping the menu
    bool menu_loop = true;
    while (menu_loop == true){
        cout << "*** Which function would you like to test? ***\n"
             << "Create Custom Objects to Unlock More Functions\n"
             << "[A] Display the Stats of the Default Prize\n"
             << "[B] Display the Stats of the Custom Prize\n"
             << "[C] Change the Name of the Custom Prize\n"
             << "[D] Change the Value of the Custom Prize\n"
             << "[E] Display the Stats of the Default Box\n"
             << "[F] Display the Stats of the Custom Box\n"
             << "[G] Change the Number of the Custom Box\n"
             << "[H] Change the Color of the Custom Box\n"
             << "[I] Add the Default Prize to the Custom Box\n"
             << "[J] Add the Custom Prize to the Custom Box\n"
             << "[K] List all the Prizes in the Custom Box\n"
             << "[L] Remove a Specific Prize from the Custom Box\n"
             << "[M] Compare two Prizes from the Custom Box\n"
             << "        [Q] to Quit the Interactive Test\n"
             << " ";
        user_choice = reader.readChar("AaBbCcDdEeFfGgHhIiJjKkLlMmNnQq");
        switch (toupper(user_choice)){
            
            //Display Name and Value of prize1
            case 'A':
                clearScreen();
                cout << "Default Prize\n" 
                     << "-Name: " << prize1.getPrizeName() << "\n"
                     << "-Value: " << prize1.getPrizeValue() << endl;
                enterToContinue();
                clearScreen();
                break;
                
            //Display Name and Value of prize2
            case 'B':
                clearScreen();
                cout << "Custom Prize\n" 
                     << "-Name: " << prize2.getPrizeName() << "\n"
                     << "-Value: " << prize2.getPrizeValue() << endl;
                enterToContinue();
                clearScreen();
                break;
                
            //Change the name of prize2
            case 'C':
                clearScreen();
                cout << "Enter the New Name for the Custom Prize: "; 
                prize2.setPrizeName(reader.readString(false));
                clearScreen();
                cout << "Custom Prize\n" 
                     << "-Name: " << prize2.getPrizeName() << "\n"
                     << "-Value: " << prize2.getPrizeValue() << endl;
                enterToContinue();
                clearScreen();
                break;
                
            //Change the value of prize2
            case 'D':
                clearScreen();
                cout << "Enter a New Value for the Custom Prize: ";
                prize2.setPrizeValue(reader.readInt(0));
                clearScreen();
                cout << "Custom Prize\n" 
                     << "-Name: " << prize2.getPrizeName() << "\n"
                     << "-Value: " << prize2.getPrizeValue() << endl;
                enterToContinue();
                clearScreen();
                break;
                
            //Display the Number, Color, and Capacity of box1
            case 'E':
                clearScreen();
                cout << "Default Box\n" 
                     << "-Number: " << box1.getBoxNumber() << "\n"
                     << "-Color: " << box1.getBoxColor() << "\n"
                     << "-Prize Count: " << box1.getPrizeCount() << "\n"
                     << "-Prize Capacity: " << box1.getPrizeCapacity() << endl;
                enterToContinue();
                clearScreen();
                break;
                
            //Display the Number, Color, and Capacity of box2
            case 'F':
                clearScreen();
                cout << "Custom Box\n" 
                     << "-Number: " << box2.getBoxNumber() << "\n"
                     << "-Color: " << box2.getBoxColor() << "\n"
                     << "-Prize Count: " << box2.getPrizeCount() << "\n"
                     << "-Prize Capacity: " << box2.getPrizeCapacity() << endl;
                enterToContinue();
                clearScreen();
                break;
                
            //Change the number of of box2
            case 'G':
                clearScreen();
                cout << "Enter a New Number for the Custom Box: ";
                box2.setBoxNumber(reader.readInt(0));
                clearScreen();
                cout << "Custom Box\n" 
                     << "-Number: " << box2.getBoxNumber() << "\n"
                     << "-Color: " << box2.getBoxColor() << "\n"
                     << "-Prize Count: " << box2.getPrizeCount() << "\n"
                     << "-Prize Capacity: " << box2.getPrizeCapacity() << endl;
                enterToContinue();
                clearScreen();
                break;
                
            //Change the color of box2
            case 'H':
                clearScreen();
                cout << "Enter a New Color for the Custom Box: ";
                box2.setBoxColor(reader.readString(false));
                clearScreen();
                cout << "Custom Box\n" 
                     << "-Number: " << box2.getBoxNumber() << "\n"
                     << "-Color: " << box2.getBoxColor() << "\n"
                     << "-Prize Count: " << box2.getPrizeCount() << "\n"
                     << "-Prize Capacity: " << box2.getPrizeCapacity() << endl;
                enterToContinue();
                clearScreen();
                break;
                
            //Add prize1 to box2 if there is room
            case 'I':
                clearScreen();
                if (box2.getPrizeCount() < box2.getPrizeCapacity()){
                    box2.addPrize(prize1);
                    cout << "***The Default Prize has been Added to the Custom Box.\n"
                         << "Custom Box\n" 
                         << "-Number: " << box2.getBoxNumber() << "\n"
                         << "-Color: " << box2.getBoxColor() << "\n"
                         << "-Prize Count: " << box2.getPrizeCount() << "\n"
                         << "-Prize Capacity: " << box2.getPrizeCapacity() << endl;
                } else {
                    cout << "The Box is full, remove a Prize to Add a new Prize.\n";
                }
                enterToContinue();
                clearScreen();
                break;
                
            //Add prize2 to box2 if there is room
            case 'J':
                clearScreen();
                if (box2.getPrizeCount() < box2.getPrizeCapacity()){
                    box2.addPrize(prize2);
                    cout << "***The Custom Prize has been Added to the Custom Box.\n"
                         << "Custom Box\n" 
                         << "-Number: " << box2.getBoxNumber() << "\n"
                         << "-Color: " << box2.getBoxColor() << "\n"
                         << "-Prize Count: " << box2.getPrizeCount() << "\n"
                         << "-Prize Capacity: " << box2.getPrizeCapacity() << endl;
                } else {
                    cout << "The Box is full, remove a Prize to Add a new Prize.\n";
                }
                enterToContinue();
                clearScreen();
                break;
                
            //Display the name and value of each prize in box2
            case 'K':
                clearScreen();
                for (unsigned int i = 0; i < box2.getPrizeCount(); i++){
                    cout << "-Name: " << box2.getPrize(i).getPrizeName() << "\n"
                         << "-Value: " << box2.getPrize(i).getPrizeValue() << "\n" << endl;
                }
                enterToContinue();
                clearScreen();
                break;
                
            //Remove a specific prize from box2, if there are prizes to remove
            case 'L':
                clearScreen();
                if (box2.getPrizeCount() > 0){
                    cout << "Which Prize would you like to Remove?\n"
                         << "(1 for first prize, 2 for second prize, etc)" << endl;
                    box2.removePrize((reader.readInt(1, box2.getPrizeCount())) - 1);
                    clearScreen();
                    cout << "***The Prize has been Removed from the Custom Box.\n"
                         << "Custom Box\n" 
                         << "-Number: " << box2.getBoxNumber() << "\n"
                         << "-Color: " << box2.getBoxColor() << "\n"
                         << "-Prize Count: " << box2.getPrizeCount() << "\n"
                         << "-Prize Capacity: " << box2.getPrizeCapacity() << endl;
                } else {
                    cout << "There are no Prizes to Remove.  Add a Prize to Remove it.\n";
                }
                enterToContinue();
                clearScreen();
                break;
                
            //Compare two prizes from box2, if there are any prizes in box2
            case 'M':
                if (box2.getPrizeCount() > 0) {
                    int choice1 = 0, choice2 = 0;
                    clearScreen();
                    cout << "Select a Prize to Compare (from Custom Box)\n"
                         << "(1 for first prize, 2 for second prize, etc)" << endl;
                    choice1 = reader.readInt(1, box2.getPrizeCount());
                    cout << "Select another Prize to Compare (from Custom Box)\n"
                         << "(1 for first prize, 2 for second prize, etc)" << endl;
                    choice2 = reader.readInt(1, box2.getPrizeCount());
                    clearScreen();
                    if (box2.getPrize(choice1 - 1) == box2.getPrize(choice2 - 1)) {
                        cout << "These Prizes are the same!!!" << endl;
                        enterToContinue();
                        clearScreen();
                    } else {
                        cout << "These Prizes are not the same." << endl;
                        enterToContinue();
                        clearScreen();
                    }
                } else {
                    clearScreen();
                    cout << "There are not enough Prizes to Compare.\n"
                         << "Add more Prizes to the Custom Box to Compare." << endl;
                    enterToContinue();
                    clearScreen();
                }
                break;
                
            //Quit the interactive test
            case 'Q':
                clearScreen();
                cout << "Thank you for running this program!\n";
                menu_loop = false;
                break;
        }
    }
}
Esempio n. 9
0
//interactive test support functions
void enterToContinue() {
    string press_enter;
    cout << "<PRESS [ENTER] TO CONTINUE>\n" << endl;
    press_enter = reader.readString(true, 0);
}
Esempio n. 10
0
int main()
{
    int choice = 0;
    int dayChoice = 0;
    int viewChoice = 0;
    bool quit = false;

    day monday;
    monday.name = "Monday";
    day tuesday;
    tuesday.name = "Tuesday";
    day wednesday;
    wednesday.name = "Wednesday";
    day thursday;
    thursday.name = "Thursday";
    day friday;
    friday.name = "Friday";
    day saturday;
    saturday.name = "Saturday";
    day sunday;
    sunday.name = "Sunday";


    while (quit == false)
    {
        bool quitSetup = false;
        bool quitView = false;

        system ("cls");
        cout << "\t\t\t-Your Daily Planner-" << endl;
        cout << "You have the options:" << endl;
        cout << "[1] Setup Each Day." << endl;
        cout << "[2] View Each Day." << endl;
        cout << "[0] Quit Program." << endl;
        cout << "\nYour choice: ";
        choice = reader.readInt (0,2);

        switch (choice)
        {
        case 1:
            while (quitSetup == false)
            {
                cout << "\nWhat day would you like to setup?\n";
                cout << "[1] Monday\n";
                cout << "[2] Tuesday\n";
                cout << "[3] Wednesday\n";
                cout << "[4] Thursday\n";
                cout << "[5] Friday\n";
                cout << "[6] Saturday\n";
                cout << "[7] Sunday\n";
                cout << "[0] Exit Setup\n";
                cout << "\nYour Choice: ";
                dayChoice = reader.readInt (0,7);
                switch (dayChoice)
                {
                case 1:
                    setupDay(monday);
                    break;
                case 2:
                    setupDay(tuesday);
                    break;
                case 3:
                    setupDay(wednesday);
                    break;
                case 4:
                    setupDay(thursday);
                    break;
                case 5:
                    setupDay(friday);
                    break;
                case 6:
                    setupDay(saturday);
                    break;
                case 7:
                    setupDay(sunday);
                    break;
                case 0:
                    quitSetup = true;
                    break;
                }
            }

            cout << "Would you like to save your data to view later? (Y) or (N)\n";
            cout << "Any unsaved data will be lost\n";
            if (toupper(reader.readChar ("YyNn"))== 'Y')
                save(&monday, &tuesday, &wednesday, &thursday, &friday, &saturday, &sunday);

            break;

        case 2:

            retrieve(&monday, &tuesday, &wednesday, &thursday, &friday, &saturday, &sunday);
            while (quitView == false)
            {
                cout << "\nWhat day would you like to view?\n";
                cout << "[1] Monday\n";
                cout << "[2] Tuesday\n";
                cout << "[3] Wednesday\n";
                cout << "[4] Thursday\n";
                cout << "[5] Friday\n";
                cout << "[6] Saturday\n";
                cout << "[7] Sunday\n";
                cout << "[0] Exit Day Viewing\n";
                cout << "\nYour Choice: ";
                viewChoice = reader.readInt (0,7);

                switch (viewChoice)
                {
                case 1:
                    system("cls");
                    printDay(monday);
                    cout << "Hit enter to continue";
                    reader.readString();
                    break;
                case 2:
                    system("cls");
                    printDay(tuesday);
                    cout << "Hit enter to continue";
                    reader.readString();
                    break;
                case 3:
                    system("cls");
                    printDay(wednesday);
                    cout << "Hit enter to continue";
                    reader.readString();
                    break;
                case 4:
                    system("cls");
                    printDay(thursday);
                    cout << "Hit enter to continue";
                    reader.readString();
                    break;
                case 5:
                    system("cls");
                    printDay(friday);
                    cout << "Hit enter to continue";
                    reader.readString();
                    break;
                case 6:
                    system("cls");
                    printDay(saturday);
                    cout << "Hit enter to continue";
                    reader.readString();
                    break;
                case 7:
                    system("cls");
                    printDay(sunday);
                    cout << "Please Hit Enter to Continue:";
                    reader.readString();
                    break;
                case 0:
                    quitView = true;
                    break;
                }
            }
            break;

        case 0:
            quit = true;

            break;
        }
    }

    return 0;
}
void prizeTest(){
    CinReader prizeReader;
    Prize testPrize;
    Prize comparePrize;
    
    unsigned int prizeMenuChoice = 0;
    char updateChoice;
    
    string newPrizeName;
    unsigned int newPrizeValue;
	
    // CODE HERE -- INTERACTIVE TEST FOR PRIZE
	do {
	    updateChoice = 'a';
		clearScreen();
		//menu here
		cout << "Prize info -> " << testPrize.getPrizeName() << ", $" << testPrize.getPrizeValue() << '\n';
        cout << "[1] Prize name\n";
	    cout << "[2] Prize value\n";
	    cout << "[3] Compare two prizes\n";
	    cout << "[0] Back to main menu\n";
	    cout << "Your choice: ";
		// read in menu choice here
        prizeMenuChoice = prizeReader.readInt(true,0,3);
		clearScreen();
		
		// menu switch goes here
		switch(prizeMenuChoice){
		    case 1:
		      cout << "Prize name: " << testPrize.getPrizeName() << "\n\n";
		      cout << "update? (y/n)\n";
		      
		      updateChoice = prizeReader.readChar("YyNn");
		      
		      switch(updateChoice){
		          case 'Y': case 'y':
		           cout << "Enter a new name for the prize: ";
		           
		           newPrizeName = prizeReader.readString();
		           testPrize.setPrizeName(newPrizeName);
		           
		           cout << endl << endl << "Prize name updated.\n\n";
		           break;
		          case 'N': case 'n':
		           break;
		      }
		     break;
		    case 2:
		      cout << "Prize value: " << testPrize.getPrizeValue() << "\n\n";
		      cout << "update? (y/n)\n";
		      
		      updateChoice = prizeReader.readChar("YyNn");
		      
		      switch(updateChoice){
		          case 'Y': case 'y':
		           cout << "Enter a new value for the prize: ";
		           
		           newPrizeValue = prizeReader.readInt(true, 0, INT_MAX);
		           testPrize.setPrizeValue(newPrizeValue);
		           
		           cout << endl << endl << "Prize value updated.\n\n";
		           break;
		          case 'N': case 'n':
		           break;
		      }
		     break;
		    case 3:
		      if((testPrize.getPrizeName() == "NO NAME") && (testPrize.getPrizeValue() == 0)){
		          cout << "Please enter an initial prize to compare to.\n\n";
		          cout << "Enter a new name for the prize: ";
		           
		          newPrizeName = prizeReader.readString();
		          testPrize.setPrizeName(newPrizeName);
		           
		          cout << "Enter a new value for the prize: ";
		           
		          newPrizeValue = prizeReader.readInt(true, 0, INT_MAX);
		          testPrize.setPrizeValue(newPrizeValue);
		      }
		      
		      cout << "Please enter details for a separate prize to compare to the stored prize.\n\n";
		      cout << "Enter a new name for the prize: ";
		           
		          newPrizeName = prizeReader.readString();
		          comparePrize.setPrizeName(newPrizeName);
		           
		          cout << "Enter a new value for the prize: ";
		           
		          newPrizeValue = prizeReader.readInt(true, 0, INT_MAX);
		          comparePrize.setPrizeValue(newPrizeValue);
		          
		          bool prizes_are_same = (testPrize == comparePrize);
		          
		      cout << endl << endl << "The two prizes are ";
		      if(prizes_are_same){
		          cout << "the same.\n\n";
		      }else{
		          cout << "not the same.\n\n";
		      }
		     break;
		}
		
		if (prizeMenuChoice > 0) {
			cout << endl << "Press ENTER to continue";
			prizeReader.readString();
		}
	} while (prizeMenuChoice != 0);
}
void boxTest(){
    CinReader boxReader;
    Box testBox;
    Prize testPrize;
    Prize removedPrize;
    
    char updateChoice;
    unsigned int boxMenuChoice = 0;
    unsigned int removeChoice = 0;
    unsigned int newBoxNumber;
    unsigned int newPrizeValue;
    string newBoxColor;
    string newPrizeName;
    bool prizeAdded;
    bool prizeRemoved;
	
    // CODE HERE -- INTERACTIVE TEST FOR BOX
	do {
		clearScreen();
		//menu here
		cout << "Box info -> " << testBox.getBoxNumber() << ", " << testBox.getBoxColor() << endl;
        cout << "[1] Add prize\n";
	    cout << "[2] View prizes\n";
	    cout << "[3] Remove prize\n";
	    cout << "[4] Box number\n";
	    cout << "[5] Box color\n";
	    cout << "[6] View prize capacity\n";
	    cout << "[7] View prize count\n";
	    cout << "[0] Back to main menu\n";
	    cout << "Your choice: ";
		// read in menu choice here
        boxMenuChoice = boxReader.readInt(true,0,7);
		clearScreen();
		
		// menu switch goes here
		switch(boxMenuChoice){
		    case 1:
		          prizeAdded = false;
		          cout << "Enter a new name for the prize: ";
		          newPrizeName = boxReader.readString();
		           
		          cout << "Enter a new value for the prize: ";
		          newPrizeValue = boxReader.readInt(true, 0, INT_MAX);
		          
		          testPrize.setPrizeName(newPrizeName);
		          testPrize.setPrizeValue(newPrizeValue);
		          
		          prizeAdded = testBox.addPrize(testPrize);
		          
		          if(prizeAdded){
		              cout << endl << endl << "Prize added.\n\n";
		          }else{
		              cout << endl << endl << "Prize unable to be added.\n\n";
		          }
		     break;
		    case 2:
		          cout << "Prizes: \n\n";
		          for(int i=0; i<testBox.getPrizeCount(); i++){
		              Prize prize_at_index;
		              prize_at_index = testBox.getPrize(i);
		              cout << i+1 << ": " << prize_at_index.getPrizeName() << endl;
		          }
		     break;
		    case 3:
		          prizeRemoved = false;
		          cout << "Choose from the list of prizes to be removed (type 0 to exit):\n\n";
		          for(int i=0; i<testBox.getPrizeCount(); i++){
		              Prize prize_at_index;
		              prize_at_index = testBox.getPrize(i);
		              cout << i+1 << ": " << prize_at_index.getPrizeName() << endl;
		          }
		          
		          cout << "Choice here: ";
		          removeChoice = boxReader.readInt(true, 0, testBox.getPrizeCount());
		          if(removeChoice == 0){
		            break;
		          }
		          
		          removedPrize = testBox.removePrize(removeChoice-1);
		          
		          cout << "\n\nPrize " << removedPrize.getPrizeName() << " has been removed.\n\n";
		          
		     break;
		    case 4:
		          cout << "\nBox number is " << testBox.getBoxNumber() << "\n\n";
		          cout << "update? (y/n)\n";
		      
		          updateChoice = boxReader.readChar("YyNn");
		      
		          switch(updateChoice){
		          case 'Y': case 'y':
		             cout << "Enter a new value for the box number: ";
		           
		             newBoxNumber = boxReader.readInt(true, 0, INT_MAX);
		             testBox.setBoxNumber(newBoxNumber);
		           
		             cout << endl << endl << "Box number updated.\n\n";
		           break;
		          case 'N': case 'n':
		           break;
		          }
		     break;
		    case 5:
		          cout << "\nBox color is " << testBox.getBoxColor() << "\n\n";
		          cout << "update? (y/n)\n";
		      
		          updateChoice = boxReader.readChar("YyNn");
		      
		          switch(updateChoice){
		          case 'Y': case 'y':
		             cout << "Enter a new value for the box color: ";
		           
		             newBoxColor = boxReader.readString();
		             testBox.setBoxColor(newBoxColor);
		           
		             cout << endl << endl << "Box color updated.\n\n";
		           break;
		          case 'N': case 'n':
		          break;
		          }
		     break;
		    case 6:
		          cout << "\nMaximum prizes that can be put in the box: " << testBox.getPrizeCapacity() << "\n\n";
		     break;
		    case 7:
		          cout << "\nPrizes in the box: " << testBox.getPrizeCount() << "\n\n";
		     break;
		}
		
		if (boxMenuChoice > 0) {
			cout << endl << "Press ENTER to continue";
			boxReader.readString();
		}
	} while (boxMenuChoice != 0);
}