Esempio n. 1
0
//******************************************************
// FUNC     :REPORT MENU SCREEN (COMPLETE)
//******************************************************
void Display_Rep(){
z:
    vector<BookRecord> Rep = Invent.getBooks();
    Report BookstoreReport(Rep);
    Clear_Screen();
    BaseMenu* baseMenuPtr;
    ReportMenu repMenu;
    baseMenuPtr = &repMenu;
    baseMenuPtr->printMenu();
    cout << endl;
    cout << "\nEnter your choice: ";
    int choice;
    cin >> choice;
    switch (choice) {
        case 1:{
            Clear_Screen();
            BookstoreReport.reportInventoryList();
            cout << "Do you want to continue (y/n)?: ";
            char ans;
            cin >> ans;
            if (ans == 'y' || ans == 'Y')
                goto z;
            else
                goto end;
        }
        case 2:{
            Clear_Screen();
            BookstoreReport.reportWholesale();
            cout << "Do you want to continue (y/n)?: ";
            char ans;
            cin >> ans;
            if (ans == 'y' || ans == 'Y')
                goto z;
            else
                goto end;
        }
        case 3:{
            Clear_Screen();
            BookstoreReport.reportRetail();
            cout << "Do you want to continue (y/n)?: ";
            char ans;
            cin >> ans;
            if (ans == 'y' || ans == 'Y')
                goto z;
            else
                goto end;
        }
        case 4:{
            Clear_Screen();
            BookstoreReport.reportQuantity();
            cout << "Do you want to continue (y/n)?: ";
            char ans;
            cin >> ans;
            if (ans == 'y' || ans == 'Y')
                goto z;
            else
                goto end;
        }
        case 5:{
            Clear_Screen();
            BookstoreReport.reportCost();
            cout << "Do you want to continue (y/n)?: ";
            char ans;
            cin >> ans;
            if (ans == 'y' || ans == 'Y')
                goto z;
            else
                goto end;
        }
        case 6:{
            Clear_Screen();
            BookstoreReport.reportAge();
            cout << "Do you want to continue (y/n)?: ";
            char ans;
            cin >> ans;
            if (ans == 'y' || ans == 'Y')
                goto z;
            else
                goto end;
        }
        case 7:{
        end:
            Rep.clear();
            Clear_Screen();
            Display_Main();
        }
            
    }
}
Esempio n. 2
0
//******************************************************
// FUNC     :CASHIER SCREEN (INCOMPLETE)
//******************************************************
void Display_Cash(){
    vector<BookRecord>& rep = Invent.getBooks();
    Cashier BookStoreCashier(rep);
z:
    Clear_Screen();
    BaseMenu *baseMenuPtr;
    CashierMenu cashMenu;
    baseMenuPtr = &cashMenu;
    baseMenuPtr->printMenu();
    cout << "\nEnter your choice: ";
    int choice;
    cin >> choice;
    cout << endl;
    switch (choice) {
        case 3:{
            Clear_Screen();
            string ISBNTemp;
            cout << "Enter the ISBN for the Book: ";
            cin >> ISBNTemp;
            BookStoreCashier.lookupBook(ISBNTemp);
            cout << "Do you want to continue (y/n)?: ";
            char ans;
            cin >> ans;
            if (ans == 'y' || ans == 'Y')
                goto z;
            else
                goto end;
        }
        case 2:{
            Clear_Screen();
            string ISBNTemp;
            cout << "Enter the ISBN for the Book: ";
            cin >> ISBNTemp;
            BookStoreCashier.returnBook(ISBNTemp);
            cout << "Do you want to continue (y/n)?: ";
            char ans;
            cin >> ans;
            if (ans == 'y' || ans == 'Y')
                goto z;
            else
                goto end;
        }
        case 1:{
            const double Sales_Tax = 0.10;
            vector<BookRecord>& rep = Invent.getBooks();
            Cashier BookStoreCashier(rep);
            int counter = 0;
            vector<string> bookISBN;
            vector<double> bookQuantity;
            vector<double> subTotals;
            bool morebook = true;
            while (morebook){
                string x;
                long y;
                cout << "Enter ISBN of purchased book" << endl;
                cin >> x;
                cout << "Enter Quantity of books purchased" << endl;
                cin >> y;
                bookISBN.push_back(x); // Vector of book ISBNs
                bookQuantity.push_back(y); // Vector of book quantities 
                cout << "Do you have more books (y/n)?: ";
                char ans;
                cin >> ans;
                if (ans == 'y' || ans == 'Y'){
                    counter++;
                }else{
                    morebook = false;
                }
            }
            for (int i = 0; i < bookISBN.size(); i++){
                long j = BookStoreCashier.searchBooks(bookISBN[i]); // Search if ISBNS exist
                if (j < 0){
                    cout<<"ERROR: BOOK NOT FOUND"<<endl;
                    return;
                }
                long k = rep[j].quantityOnHand;
                // Check to see if quantity on hand is less than quantity requested 
                if (k<bookQuantity[i]){
                    cout << "Not Enough "<<rep[j].title<<" in Store, only "<< k << endl;
                    bookQuantity[i] = k;
                    rep[j].quantityOnHand = 0;
                }else{
                    cout << "Quanity decrease by "<<bookQuantity[i]<<" Current amount: "<<rep[j].quantityOnHand<<endl;
                    for(int i =0; i< bookQuantity[i]; i++)
                    rep[j].quantityOnHand -=  bookQuantity[i];
                }
            }
            for (int i = 0; i < bookISBN.size(); i++){
                long j = BookStoreCashier.searchBooks(bookISBN[i]);
                subTotals.push_back(rep[j].retailPrice * bookQuantity[i]);
            }
            
            Clear_Screen();
            cout << "Group 3's Bookstore" << endl<<endl;
            time_t t = time(0);
            struct tm * now = localtime( & t );
            cout << "Date: "<<(now->tm_year + 1900) << '-' << (now->tm_mon + 1) << '-'<<  now->tm_mday<< endl<<endl<<endl;
            cout <<setw(10) <<left << "QTY" <<setw(20) <<left << "ISBN" <<setw(30)  <<"Title"<<setw(20)<<left<<"Price($)"<<setw(10)<<left<<"Total($)"<<endl;
            cout<<"-----------------------------------------------------------------------------------------------"<<endl;
            double finalTotal_preTax = 0;
            for (int i = 0; i <bookISBN.size();i++){
                string title;
                for (int j = 0; j < rep.size(); j++){
                    int x = BookStoreCashier.searchBooks(bookISBN[i]);
                    title = rep[x].title;
                }
                cout <<setw(10) <<left << bookQuantity[i] <<setw(20) <<left << bookISBN[i];
                    if (title.size()>30){
                        cout << setw(30) << left << string(title.begin(),title.begin()+25);
                    }
                    else{
                        cout << setw(30) << left << title;
                    }

                cout<<setw(20)<<left<<setprecision(2)<<fixed<<subTotals[i]<<setw(10)<<left<<subTotals[i]*Sales_Tax+subTotals[i]<<endl;
                finalTotal_preTax += subTotals[i];
            }
            
            cout << endl<<endl;
            cout <<setprecision(2);
            cout << setw(30) <<right<<fixed<<setprecision(2)<<"SubTotal: $"<< finalTotal_preTax<<endl;
            cout << setw(30) <<right<<fixed<<setprecision(2)<<"Tax: $"<<finalTotal_preTax*Sales_Tax<<endl;
            cout << setw(30) <<right<<setprecision(2)<<fixed<<"Total: $"<< finalTotal_preTax+finalTotal_preTax*Sales_Tax;
            cout<<endl;
            cout << "Do you want to continue (y/n)?: ";
            char ans;
            cin >> ans;
            if (ans == 'y' || ans == 'Y')
                goto z;
            else{
                bookISBN.clear();
                bookQuantity.clear();
                subTotals.clear();
                goto end;
            }
        }
        case 4:{
        end:
            Clear_Screen();
            Display_Main();
        }
    }
}