1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
#include"Fruit.h"
#include"arrayListType.h"
#include"fruitArrayType.h"
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
//Function prototypes
void showMenu(Fruit MenuList[],int s);
int main()
{
const int SIZE = 8;
int choice;
double Quan;
char changeQty;
int newqty;
Fruit newItem;
fruitArrayType ShoppingList;
Fruit MenuList[SIZE]= {Fruit("Apple", 0.99), Fruit("Apricot", 0.45), Fruit("Avocado", 1.50), Fruit("Banana", 0.75),
Fruit("Blueberry", 1.00), Fruit("Grape", 1.25), Fruit("Orange", 1.50), Fruit("Pear ", 1.30)};
do
{
showMenu(MenuList,SIZE);
cout << "\nPlease enter the number of your selection(1--9). \n";
cin >> choice;
if(choice ==9){break;}
if(choice < 1 || choice > 9)
{
cout << "\a\a Invalid Input \n";
cout << "\nPlease enter the number of your selection(1--9). \n";
cin >> choice;
}
newItem = MenuList[choice -1];
cout << "\nPlease enter the quantity of " << MenuList[choice-1].getN() <<":\n";
cin >> Quan;
if(Quan < 0)
{
cout <<"\a\a Invalid quantity. \n";
cout << "\nPlease enter the quantity of " << MenuList[choice-1].getN() <<":\n";
cin >> Quan;
}
newItem.setQ(Quan);
ShoppingList.insertEnd(newItem);
while (choice != 9 && Quan >= 0)
{
ShoppingList.print();
cout << "\nDo you want to change the quantity of the item? (Y/N). \n";
cin>> changeQty;
if (changeQty == 'Y')
{
cout << "Which item number? \n";
cin>> newqty;
ShoppingList.updateL(num, newqty);
ShoppingList.print(num);
}
else
break;
}
}while (choice != 9);
return 0;
}
void showMenu(Fruit MenuList[], int s) //Show menu function definition
{
cout << "Welcome to Cooper's Fresh Fruit Store! \n\n";
cout << " Items " << setw(25) << "Unit Price \n";
for(int count = 0; count < s; count++)
{
cout << "#" << count+1 <<" "
<< MenuList[count].name << "\t\t$"
<< MenuList[count].price << "/lb\n";
}
cout <<"#9 Exit \n";
}
/*
void TotalCost(Fruit ShoppingList[], int counter) //Total Cost function def.
{
double FinalTotal;
for(int count = 0; count < counter; count++)
{
FinalTotal+= ShoppingList[count].getC();
}
cout << "****************************************************************** \n";
cout << setw(25) << left << "Total Cost" <<fixed << showpoint <<setprecision(2)<<"$"<<FinalTotal << "\n";
}
*/
|