Advertisement
skb50bd

Project

Aug 16th, 2015
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 23.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. #include <iomanip>
  5. #include <cstdlib>
  6. #include <fstream>
  7. #include <cmath>
  8. #define R2G 0.12149792
  9.  
  10. using namespace std;
  11.  
  12. //######FUNCTION TO PRINT SHOP TITLE######
  13. void shopTitle() {
  14.     cout << endl;
  15.     cout << endl <<  "  ______      _____       _          _   _                  _ ________          ________ _      _      ______ _____   _____  ";
  16.     cout << endl <<  " |  ____/\\   |  __ \\     | |   /\\   | \\ | |   /\\           | |  ____\\ \\        / /  ____| |    | |    |  ____|  __ \\ / ____| ";
  17.     cout << endl <<  " | |__ /  \\  | |__) |    | |  /  \\  |  \\| |  /  \\          | | |__   \\ \\  /\\  / /| |__  | |    | |    | |__  | |__) | (___   ";
  18.     cout << endl <<  " |  __/ /\\ \\ |  _  / _   | | / /\\ \\ | . ` | / /\\ \\     _   | |  __|   \\ \\/  \\/ / |  __| | |    | |    |  __| |  _  / \\___ \\  ";
  19.     cout << endl <<  " | | / ____ \\| | \\ \\| |__| |/ ____ \\| |\\  |/ ____ \\   | |__| | |____   \\  /\\  /  | |____| |____| |____| |____| | \\ \\ ____) | ";
  20.     cout << endl <<  " |_|/_/    \\_\\_|  \\_\\\\____//_/    \\_\\_| \\_/_/    \\_\\   \\____/|______|   \\/  \\/   |______|______|______|______|_|  \\_\\_____/  ";
  21.     cout << endl << endl;
  22.     for (int i = 0; i < 32; i++) cout << "-";
  23.     cout << "XX XXXXXXX, XXXXXX XXXXXX (1st Floor), Tongi Bazar, Gazipur.";
  24.     for (int i = 0; i < 32; i++) cout << "-";
  25.     cout << endl;
  26.     for (int i = 0; i < 36; i++) cout << "-";
  27.     cout << "A Reliable Shop for Getting the Best Quality Jewelry";
  28.     for (int i = 0; i < 36; i++) cout << "-";
  29.     cout << endl << endl;
  30. }
  31.  
  32.  
  33.  
  34. //*****PRICE/RATE CLASS******
  35. //This Class's Objects Contains Gold Price According to Corresponding Karat
  36. class Rate{
  37. protected:
  38.     string date;
  39.     double k18, k20, k21, k22;
  40. public:
  41.     Rate(): date("N/A"), k18(0.0), k20(0.0), k21(0.0), k22(0.0) {} //0-arg Constructor
  42.     Rate(double k180, double k200, double k210, double k220): k18(k180), k20(k200), k21(k210), k22(k220) {} //4-arg Constructor
  43.     ~Rate() {} //Destructor
  44.  
  45.     void read(string dt) {
  46.         cout << "Update the Current GOLD Price." << endl;
  47.         date = dt;
  48.         cin.sync();
  49.         cout << "Input the Price in Grams/Tola: (g/t): ";
  50.         char un;
  51.         do{
  52.             cin >> un;
  53.             cin.sync();
  54.         } while(un != 'g' && un != 't' && un != 'G' && un != 'T');
  55.  
  56.         cout << "Enter Price for All Corresponding Karat Values";
  57.         (un == 'g' || 'G') ? cout << " (in GRAMS) : " << endl : cout << " (in TOLA) : " << endl;
  58.         cout << "Today's Price for 18K Gold: ";
  59.         cin >> k18;
  60.         cout << "Today's Price for 20K Gold: ";
  61.         cin >> k20;
  62.         cout << "Today's Price for 21K Gold: ";
  63.         cin >> k21;
  64.         cout << "Today's Price for 22K Gold: ";
  65.         cin >> k22;
  66.  
  67.         if(un == 't' || un == 'T') {
  68.             k18 = k18 * 96 * R2G;
  69.             k20 = k20 * 96 * R2G;
  70.             k21 = k21 * 96 * R2G;
  71.             k22 = k22 * 96 * R2G;
  72.         }
  73.         cout << "***Gold Price Successfully Updated***" << endl << endl;
  74.     }
  75.  
  76.     void display() {
  77.         cout << date << "'s Gold Price List" << endl;
  78.         cout << left << setw(15) << "KARATS" << right << setw(15) << "PRICE(Gram)" << right << setw(15) << "PRICE(Tola)" << endl;
  79.         cout << left << setw(15) << "18-K" << right << setw(15) << setprecision(2) << k18 << right << setw(15) << setprecision(2) << k18 / R2G * 96 << endl;
  80.         cout << left << setw(15) << "20-K" << right << setw(15) << setprecision(2) << k20 << right << setw(15) << setprecision(2) << k20 / R2G * 96 << endl;
  81.         cout << left << setw(15) << "21-K" << right << setw(15) << setprecision(2) << k21 << right << setw(15) << setprecision(2) << k21 / R2G * 96 << endl;
  82.         cout << left << setw(15) << "22-K" << right << setw(15) << setprecision(2) << k22 << right << setw(15) << setprecision(2) << k22 / R2G * 96 << endl;
  83.         for(int i = 0; i < 45; i++)
  84.             cout << "-";
  85.         cin.sync();
  86.         getchar();
  87.         cin.sync();
  88.         cout << endl << endl << endl;
  89.  
  90.     }
  91.  
  92.     //Function to return Price
  93.     double getPrice(int k) {
  94.         if(k == 18) return k18;
  95.         else if(k == 20) return k20;
  96.         else if(k == 21) return k21;
  97.         else if(k == 22) return k22;
  98.         else {
  99.             cout << "***Invalid Karat Value, Try Again***" << endl;
  100.             return -1;
  101.         }
  102.     }
  103.  
  104.     string getDate() {return date;}
  105. };
  106. Rate R;
  107.  
  108. //******UNIT CLASS******
  109. //This is South Asian Standard Gold Weight Measurement Scale
  110. class Tola{
  111. protected:
  112.     int bhari;
  113.     int anni;
  114.     double ratti;
  115.  
  116. public:
  117.     Tola(): bhari(0), anni(0), ratti(0.0) {} //0-arg Constructor
  118.     Tola(int bh, int an, double rt): bhari(bh), anni(an), ratti(rt) {} //3-arg Constructor (This Takes Assigns Inputs in Tola type)
  119.     Tola(double grams){ //1-arg Constructor (Converts GRAMS to TOLA type)
  120.         ratti = grams / R2G;
  121.         int int_ratti = ratti;
  122.         bhari = ratti / 96;
  123.         anni = (int_ratti % 96) / 6;
  124.         ratti = (int_ratti % 96 % 6) + ratti - int_ratti;
  125.     }
  126.  
  127.     ~Tola() {}
  128.  
  129.     int getBhari() { return bhari;}
  130.     int getAnni() { return anni;}
  131.     double getRatti() {return ratti;}
  132.  
  133.     void readTola() {
  134.         cin.sync();
  135.         cout << "Enter Ornament weight in TOLA (Bhari Anni Ratti): ";
  136.         cin >> bhari >> anni >> ratti;
  137.     }
  138.  
  139.     void showTola() {
  140.         cout.setf(ios::fixed);
  141.         cout << bhari << "-Bhari " << anni << "-Anni " << setprecision(1) << ratti << "-Ratti" << setprecision(2);
  142.     }
  143.  
  144.     operator double() { return ((bhari * 96) + (anni * 6) + ratti) * R2G;}
  145. };
  146.  
  147.  
  148.  
  149. //******ORNAMENT CLASS******
  150. //This Class is for General Ornaments Attributes
  151. class Ornament: public Tola{
  152. protected:
  153.     string id;
  154.     string type;
  155.     string description;
  156.     int karat;
  157.     double weight;
  158.     Ornament *next;
  159.  
  160. public:
  161.     Ornament(): id("N/A"), type("N/A"), description("N/A"), karat(0), weight(0.0), next(NULL){ Tola();}
  162.     ~Ornament() {}
  163.  
  164.     double calculatePrice() {
  165.         return (R.getPrice(karat) * weight);
  166.     }
  167.  
  168.     void setNext(Ornament *P) { next = P;}
  169.     Ornament * getNext() { return next;}
  170.  
  171.     void display() {
  172.         cout << left << setw(15) << "TYPE" <<  left << setw(7) << "ID" << right << setw(7) << "KARAT" << right << setw(11) << "GRAM" << right << setw(11) << "TOLA" << right  << "  " << left << "DSCRIPTION" << endl;
  173.         cout << left << setw(15) << type <<  left << setw(7) << id << right << setw(7) << karat << right << setw(11) << setprecision(2) << weight << right << setw(4) << bhari << "." << setw(2) << anni <<  "." << setw(3) << setprecision(1) << ratti << right  << "  " << left << description << endl;
  174.     }
  175.  
  176.     string getID() { return id;}
  177.     string getType() { return type;}
  178.     int getKarat() { return karat;}
  179.     double getWeight() { return weight;}
  180.     void swap(Ornament *);
  181.     void sort();
  182.     Ornament * searchID(string);
  183.     Ornament * deleteOrnID(string);
  184.     void read();
  185.     friend void listStock(Ornament *);
  186. };
  187.  
  188.  
  189. class Sale{
  190. private:
  191.     string name;
  192.     string address;
  193.     string date;
  194.     Ornament *Start;
  195.     double total_amount;
  196.     Sale *next;
  197. public:
  198.     Sale():date("N/A"), next(NULL), total_amount(0.0) {}
  199.     ~Sale() {}
  200.     void setNext(Sale *P) { next = P;}
  201.     Sale * getNext() { return next;}
  202.  
  203.     Ornament * read(Ornament *OrnHead, string dt){
  204.         cout.setf(ios::fixed);
  205.         ifstream in;
  206.         ofstream out;
  207.         Ornament *Current;
  208.         Ornament *Orn[10];
  209.         string id;
  210.         string str;
  211.         char ch;
  212.         date = dt;
  213.  
  214.         cout << "Date: " << date << endl << "Enter Customer's Name: ";
  215.         cin.sync();
  216.         getline(cin, name);
  217.         cout << "Enter Address: ";
  218.         getline(cin, address);
  219.         cin.sync();
  220.  
  221.         int i = 0;
  222.         while(i < 10) {
  223.             cout << "Enter Ornament "<< i + 1 << " ID: ";
  224.             cin.sync();
  225.             cin >> id;
  226.             cin.sync();
  227.             Orn[i] = OrnHead -> searchID(id);
  228.             if(Orn[i] == 0){
  229.                 cout << "ID match NOT Found. Try Again." << endl;
  230.                 cout << "Continue (y/n) ?  ";
  231.                 cin.sync();
  232.                 cin >> ch;
  233.                 cin.sync();
  234.                 if(ch == 'y') continue;
  235.                 else {
  236.                     i--;
  237.                     break;
  238.                 }
  239.             }
  240.             else {
  241.                 cout << "ID match Found." << endl << "Product: " << endl;
  242.                 Orn[i] -> display();
  243.                 cout << "Price: " << Orn[i] -> calculatePrice() << endl;
  244.                 cout << "Press \'y\' to Confirm: ";
  245.                 cin >> ch;
  246.                 if(ch != 'y') continue;
  247.             }
  248.  
  249.             cout << "Continue (y/n) ? ";
  250.             cin >> ch;
  251.  
  252.             if(ch == 'n') {
  253.                 cout << endl << endl;
  254.                 break;
  255.             }
  256.  
  257.             if(i == 9) cout << "You Have Taken the Maximum Amount of Items." << endl << "For more, get a new Receipt." << endl << endl;
  258.             i++;
  259.         }
  260.  
  261.         if(Orn[0] == NULL){
  262.             cout << "NO ITEM PURCHASED" << endl;
  263.             return OrnHead;
  264.         }
  265.  
  266.         int item = i + 1;
  267.         out.open("Receipt.txt", ios::app);
  268.  
  269.         out << endl;
  270.         out << endl <<  "  ______      _____       _          _   _                  _ ________          ________ _      _      ______ _____   _____  ";
  271.         out << endl <<  " |  ____/\\   |  __ \\     | |   /\\   | \\ | |   /\\           | |  ____\\ \\        / /  ____| |    | |    |  ____|  __ \\ / ____| ";
  272.         out << endl <<  " | |__ /  \\  | |__) |    | |  /  \\  |  \\| |  /  \\          | | |__   \\ \\  /\\  / /| |__  | |    | |    | |__  | |__) | (___   ";
  273.         out << endl <<  " |  __/ /\\ \\ |  _  / _   | | / /\\ \\ | . ` | / /\\ \\     _   | |  __|   \\ \\/  \\/ / |  __| | |    | |    |  __| |  _  / \\___ \\  ";
  274.         out << endl <<  " | | / ____ \\| | \\ \\| |__| |/ ____ \\| |\\  |/ ____ \\   | |__| | |____   \\  /\\  /  | |____| |____| |____| |____| | \\ \\ ____) | ";
  275.         out << endl <<  " |_|/_/    \\_\\_|  \\_\\\\____//_/    \\_\\_| \\_/_/    \\_\\   \\____/|______|   \\/  \\/   |______|______|______|______|_|  \\_\\_____/  ";
  276.         out << endl << endl;
  277.         for (int i = 0; i < 32; i++) out << "-";
  278.         out << "XX XXXXXXX, XXXXXX XXXXXX (1st Floor), Tongi Bazar, Gazipur.";
  279.         for (int i = 0; i < 32; i++) out << "-";
  280.         out << endl;
  281.         for (int i = 0; i < 36; i++) out << "-";
  282.         out << "A Reliable Shop for Getting the Best Quality Jewelry";
  283.         for (int i = 0; i < 36; i++) out << "-";
  284.         out << endl;
  285.         for (int i = 0; i < 55; i++) out << "-";
  286.         out << "MONEY RECEIPT";
  287.         for (int i = 0; i < 56; i++) out << "-";
  288.         out << endl;
  289.  
  290.  
  291.         out << left << setw(9) << "NAME: " << name << endl;
  292.         out << left << setw(9) << "ADDRESS: " << address << endl;
  293.         out << left << setw(9) << "DATE: " << date << endl << endl << endl;
  294.  
  295.         out << left << setw(10) << "No." << left << setw(20) << "ITEM ID" << left << setw(33) << "ITEM TYPE" << right << setw(18) << setprecision(2) << "WEIGHT" << right << setw(15) << setprecision(2) << "PRICE" << endl;
  296.  
  297.         for(i = 0; i < item; i++) {
  298.             out << left << setw(10) << i + 1 << left << setw(20) << Orn[i] -> getID() << left << setw(33) << Orn[i] -> getType() << right << setw(18) << setprecision(2) << Orn[i] -> getWeight() << right << setw(15) << setprecision(2) << Orn[i] -> calculatePrice() << endl;
  299.             total_amount += Orn[i] -> calculatePrice();
  300.         }
  301.         for(int l = 0; l < 124; l++) out << "-";
  302.  
  303.         out << right << setw(103) << "TOTAL AMOUNT" << "  " << left << setw(14) << setprecision(2) << total_amount << endl << endl << endl;
  304.         for(int l = 0; l < 124; l++) out << "-";
  305.         out << endl << endl;
  306.         out << left << setw(62) << "Consumer's Signature" << right << setw(62) << "Proprietor's Signature" << endl;
  307.         out << "THANK YOU. COME AGAIN!!!";
  308.         out.close();
  309.  
  310.  
  311.         cout << "Receipt Generated." << endl << "Do you want to check the receipt (y/n) ? ";
  312.         cin >> ch;
  313.         if(ch == 'y') {
  314.             in.open("Receipt.txt");
  315.             while(getline(in, str))
  316.                 cout << str << endl;
  317.             in.close();
  318.         }
  319.  
  320.         cout << endl << endl;
  321.         cout << "Deleting Sold Items from Stock" << endl;
  322.         for(i = 0; i < item; i++) //DELETING the SOLD ORNAMENTS from STOCK
  323.             OrnHead = OrnHead -> deleteOrnID(Orn[i] -> getID());
  324.  
  325.         return OrnHead;
  326.     }
  327.  
  328. };
  329.  
  330.  
  331. //Read Ornament Detail While Registering Stock
  332. void Ornament :: read() {
  333.     int int_ratti;
  334.     unsigned short int Karat;
  335.     char yn;
  336.     cout << endl << endl << "Enter Ornament ID: ";
  337.     cin.sync();
  338.     cin >> id;
  339.     cout << "Enter Ornament Type: ";
  340.     cin.sync();
  341.     getline(cin, type);
  342.     while(true) {
  343.         cin.sync();
  344.         cout << "Do you want to include Description (y/n)? ";
  345.         cin >> yn;
  346.         cin.sync();
  347.         if(yn == 'Y' || yn == 'y') {
  348.             cout << "Description: ";
  349.             cin.sync();
  350.             getline(cin, description);
  351.             cin.sync();
  352.             break;
  353.         }
  354.         else if(yn == 'N' || yn == 'n') {
  355.             cout << "***Description skipped***" << endl;
  356.             break;
  357.         }
  358.         else
  359.             cout << "Invalid Input, Try Again." << endl;
  360.     }
  361.     cin.sync();
  362.     while(true){ //KARAT INPUT
  363.         cout << "Enter Ornament Karat: ";
  364.         cin >> Karat;
  365.         if(Karat == 18 || Karat == 20 || Karat == 21 || Karat == 22) {
  366.             karat = Karat;
  367.             break;
  368.         }
  369.         else cout << "Invalid Karat Value, Try Again." << endl;
  370.     }
  371.     while(true) {
  372.         cout << "Input Weight in Gram/Tola (g/t): ";
  373.         cin.sync();
  374.         cin >> yn;
  375.         cin.sync();
  376.         if(yn == 'G' || yn == 'g'){
  377.             cout << "Enter Ornament Weight in GRAM: ";
  378.             cin.sync();
  379.             cin >> weight;
  380.             cin.sync();
  381.             weight = fabs(weight);
  382.             ratti = weight / R2G;
  383.             int_ratti = ratti;
  384.             bhari = ratti / 96;
  385.             anni = (int_ratti % 96) / 6;
  386.             ratti = (int_ratti % 96 % 6) + ratti - int_ratti;
  387.             break;
  388.         }
  389.         else if(yn == 'T' || yn == 't') {
  390.             readTola();
  391.             weight = Tola(bhari, anni, ratti);
  392.             break;
  393.         }
  394.         else cout << "Invalid input, Try Again." << endl;
  395.     }
  396. }
  397.  
  398.  
  399. //Display All the Ornaments
  400. void listStock(Ornament *Head) {
  401.     Ornament *OrnCurrent;
  402.     cout << left << setw(15) << "TYPE" <<  left << setw(7) << "ID" << right << setw(7) << "KARAT" << right << setw(11) << "GRAM" << right << setw(11) << "TOLA" << right  << "  " << left << "DSCRIPTION" << endl;
  403.     for(OrnCurrent = Head; OrnCurrent != NULL; OrnCurrent = OrnCurrent -> getNext())
  404.         cout << left << setw(15) << OrnCurrent -> type <<  left << setw(7) << OrnCurrent -> id << right << setw(7) << OrnCurrent -> karat << right << setw(11) << setprecision(2) << OrnCurrent -> weight << right << setw(4) << OrnCurrent -> bhari << "." << setw(2) << OrnCurrent -> anni <<  "." << setw(3) << setprecision(1) << OrnCurrent -> ratti << right  << "  " << left << OrnCurrent -> description << endl;
  405.  
  406.     cout << endl << "***End of List***" << endl << "Enter 0 to Go Back: ";
  407.     while(getchar() != '0');
  408.     cout << endl << endl;
  409. }
  410.  
  411.  
  412. //Searches an Ornament by ID
  413. Ornament * Ornament :: searchID(string idF) {
  414.     Ornament *Current = this;
  415.     if(this -> karat != 18 && this -> karat != 20 && this -> karat != 21 && this -> karat != 22)
  416.         return 0;
  417.     while(Current != NULL){
  418.         if(Current -> id == idF) return Current;
  419.         else Current = Current -> getNext();
  420.     }
  421.     return 0;
  422. }
  423.  
  424.  
  425. Ornament * Ornament :: deleteOrnID(string idF) {
  426.     Ornament *Current = this;
  427.     Ornament *Last;
  428.     while(Current != NULL){
  429.         if(Current -> id == idF) {
  430.             if(Current == this) {
  431.                 Last = this -> getNext();
  432.                 delete this;
  433.                 cout << "Deletion Confirmed" << endl;
  434.                 return Last;
  435.             }
  436.             else if(Current -> getNext() == NULL) {
  437.                 Last -> setNext(NULL);
  438.                 delete Current;
  439.                 cout << "Deletion Confirmed" << endl;
  440.                 return this;
  441.             }
  442.             else {
  443.                 Last -> setNext(Current -> getNext());
  444.                 delete Current;
  445.                 cout << "Deletion Confirmed" << endl;
  446.                 return this;
  447.             }
  448.         }
  449.         else {
  450.             Last = Current;
  451.             Current = Current -> getNext();
  452.         }
  453.  
  454.     }
  455.     cout << "Deletion ERROR!!!" << endl;
  456.     cout << "NO MATCH FOUND!!!" << endl;
  457.     return this;
  458. }
  459.  
  460.  
  461.  
  462.  
  463.  
  464. int main() {
  465.     cout.setf(ios::fixed);
  466.     unsigned short int updatechoice;
  467.     unsigned short int choice;
  468.     char cont;
  469.     bool saleStat = false;
  470.     string id;
  471.     string date;
  472.     string str;
  473.  
  474.     Ornament *OrnHead; //Contains the First Ornament Object
  475.     Ornament *OrnCurrent;
  476.     Ornament *OrnTail; //Contains the Last Ornament Object
  477.     Sale *SaleHead = NULL;
  478.     Sale *SaleCurrent;
  479.     Sale *SaleTail;
  480.  
  481.     ifstream in;
  482.  
  483.  
  484.  
  485.     //DISPLAY STARTS from HERE!!!
  486.     shopTitle();
  487.  
  488.     while(true) {
  489.         cout << "Welcome!!!" << endl;
  490.         cout << "Enter Todays Date: ";
  491.         cin.sync();
  492.         getline(cin, date);
  493.         cin.sync();
  494.         cout << endl << endl;
  495.  
  496.         while(true) {
  497.             cout << "-----MAIN MENU-----" << endl;
  498.             cout << "Enter 1 to Check Stock." << endl;
  499.             cout << "Enter 2 to Update Stock." << endl;
  500.             cout << "Enter 3 to Update Gold Price Rate." << endl;
  501.             cout << "Enter 4 to Check Gold Price Rate." << endl;
  502.             cout << "Enter 5 to Sell Ornaments." << endl;
  503.             cout << "Enter 6 to Check all Sales." << endl;
  504.             cout << "Enter 0 To End the Day. " << endl;
  505.  
  506.             cout << endl << "Enter Your Choice: ";
  507.             cin.sync();
  508.             cin >> choice;
  509.             cout << endl << endl;
  510.  
  511.             if(choice == 1) { //Check Stock
  512.                 if(OrnHead -> getKarat() != 18 && OrnHead -> getKarat() != 20 && OrnHead -> getKarat() != 21 && OrnHead -> getKarat() != 22 ) {
  513.                     cout << "Sorry! Stock is Empty!!! \nUpdate Stock before Checking.  ";
  514.                     cin.sync();
  515.                     getchar();
  516.                     cin.sync();
  517.                     cout  << endl << endl;
  518.                 }
  519.                 else listStock(OrnHead);
  520.             }
  521.  
  522.             else if(choice == 2) {//Update Stock
  523.                 while(true) {
  524.                     cout << "-----UPDATE STOCK-----" << endl;
  525.                     cout << "1 - Add Ornaments" << endl;
  526.                     cout << "2 - Delete Ornaments" << endl;
  527.                     cout << "0 - Go Back" << endl;
  528.                     cout << "Enter Choice: ";
  529.                     cin >> updatechoice;
  530.                     if(updatechoice == 1) { //ADD Ornaments
  531.                         while(true) {
  532.                             if(OrnHead -> getKarat() != 18 && OrnHead -> getKarat() != 20 && OrnHead -> getKarat() != 21 && OrnHead -> getKarat() != 22)
  533.                                     OrnCurrent = OrnHead = new Ornament();
  534.                             else {
  535.                                 OrnCurrent = new Ornament();
  536.                                 OrnTail -> setNext(OrnCurrent);
  537.                             }
  538.                             OrnCurrent -> read();
  539.                             OrnTail = OrnCurrent;
  540.                             cout << "Do You Want to Continue (y/n) ? ";
  541.                             cin.sync();
  542.                             cin >> cont;
  543.                             if(cont != 'y') break;
  544.                         }
  545.                         cout << endl << endl;
  546.                     }
  547.                     else if(updatechoice == 2) { //DELETE Ornaments
  548.                         while(true) {
  549.                             cout << "Enter Ornament ID to Delete from Stock: ";
  550.                             cin >> id;
  551.                             OrnHead = OrnHead -> deleteOrnID(id);
  552.                             cout << "Do You Want to Continue (y/n) ? ";
  553.                             cin >> cont;
  554.                             if(cont != 'y') break;
  555.                             cout << endl << endl;
  556.                         }
  557.                         cout << endl << endl;
  558.                     }
  559.                     else if(updatechoice == 0){
  560.                         cout << endl << endl;
  561.                         break;
  562.                     }
  563.                     else cout << "Invalid Input. Try Again" << endl << endl;
  564.                 }
  565.  
  566.             }
  567.  
  568.             else if(choice == 3) //Update Price
  569.                 R.read(date);
  570.  
  571.             else if(choice == 4) {//Check Price
  572.                 cout << "-----PRICE LIST-----" << endl;
  573.                 if(R.getDate() == "N/A") {
  574.                     cout << "Price Not Entered Yet." << endl << "Enter Price and Try Again...  ";
  575.                     cin.sync();
  576.                     getchar();
  577.                     cin.sync();
  578.                     cout << endl << endl << endl;
  579.                 }
  580.                 else R.display();
  581.             }
  582.  
  583.             else if(choice == 5) {
  584.                 if(OrnHead -> getKarat() != 18 && OrnHead -> getKarat() != 20 && OrnHead -> getKarat() != 21 && OrnHead -> getKarat() != 22 ) cout << "Sorry! Stock is Empty!!! \nUpdate Stock. " << endl << endl;
  585.                 else if(R.getDate() == "N/A") cout << "Price Not Entered Yet." << endl << "Enter Price and Try Again...  " << endl << endl;
  586.                 else{
  587.                     cout << "-----SELLING ORNAMENTS-----" << endl;
  588.                     while(true) {
  589.                         if(!saleStat) {
  590.                             SaleCurrent = SaleHead = new Sale();
  591.                             saleStat = true;
  592.                         }
  593.                         else {
  594.                             SaleCurrent = new Sale();
  595.                             SaleTail -> setNext(SaleCurrent);
  596.                         }
  597.                         OrnHead = SaleCurrent -> read(OrnHead, date);
  598.                         SaleTail = SaleCurrent;
  599.                         cout << "Do You Want to Continue (y/n) ? ";
  600.                         cin.sync();
  601.                         cin >> cont;
  602.                         cout << endl << endl;
  603.                         if(cont == 'n') break;
  604.                     }
  605.                 }
  606.              }
  607.  
  608.             else if(choice == 6) {
  609.                 cout << " ALL RECEIPTS of TODAY" << endl;
  610.                 in.open("Receipt.txt");
  611.                 while(getline(in, str))
  612.                     cout << str << endl;
  613.                 cout << endl << endl << "######  END ######" << endl << endl;
  614.                 in.close();
  615.             }
  616.  
  617.             else if(choice == 0) {
  618.                 cout << "Thank You." << endl << "Closing Shop for Today..." << endl;
  619. //DELETING ALL SALE OBJECTS
  620.             if(SaleHead != NULL) {
  621.                 for(SaleCurrent = SaleHead; SaleCurrent != NULL; SaleCurrent = SaleTail) {
  622.                     SaleTail = SaleCurrent -> getNext();
  623.                     delete SaleCurrent;
  624.                 }
  625.                 saleStat = false;
  626.             }
  627.                 break;
  628.             }
  629.  
  630.             else
  631.                 cout << "Invalid Choice!!!" << "Try Again." << endl << endl;
  632.         }
  633.  
  634.         cout << "Do You Want to Continue? (y/n) ";
  635.         cin >> cont;
  636.         if(cont == 'n' || cont == 'N') {
  637.             cout << "Exiting...." << endl;
  638.             exit(1);
  639.         }
  640.         cout << endl << endl << endl;
  641.     }
  642.  
  643.     return 0;
  644. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement