repl.it
@FishDeity/

6.15-ItemToPurchase

C++11

No description

fork
loading
Files
  • main.cpp
  • ItemToPurchase.cpp
  • ItemToPurchase.h
  • ShoppingCart.cpp
  • ShoppingCart.h
main.cpp
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
104
105
106
107
108
109
110
#include <iostream>
using namespace std;

#include "ItemToPurchase.h"
#include "ShoppingCart.h"

void PrintMenu(ShoppingCart cart) {
  bool passThru = false;
  unsigned i;
  string sampleText;
  char choice;
  vector<char> options = {'a', 'd', 'c', 'i', 'o', 'q'};

  while (passThru == false) {
    PrintMenu(cart);
    cin >> choice;
    for (i=0; i<options.size(); i++) {
      if (choice == options[i]) { passThru = true; }
    }
    cout << endl;
  }
  switch (choice) {
    case 'a':
      cart.AddItem(ItemToPurchase item); 
      break;
    case 'd':
      cart.RemoveItem();
      break;
    case 'c':      
      cout << "Enter a word or phrase to be found: " << endl;
      cin.ignore() >> sampleText;
      cout << endl;

      FindText(sampleText, input);
      break;
    case 'i':
      ReplaceExclamation(input);
      break;
    case 'o':
      ShortenSpace(input);
      break;
    case 'q':
      break;
  }

  return;
}
int main() {
  /*
  ItemToPurchase item1, item2;
  string tempStr;
  int tempInt;

  cout << "Item 1" << endl;
  cout << "Enter the item name:" << endl;
  getline(cin, tempStr);
  item1.SetItemName(tempStr);

  cout << "Enter the item price:" << endl;
  cin >> tempInt;
  item1.SetPrice(tempInt);

  cout << "Enter the item quantity:" << endl;
  cin.ignore() >> tempInt;
  item1.SetQuantity(tempInt);

  cin.ignore();
  cout << endl;

  cout << "Item 2" << endl;
  cout << "Enter the item name:" << endl;
  getline(cin, tempStr);
  item2.SetItemName(tempStr);

  cout << "Enter the item price:" << endl;
  cin >> tempInt;
  item2.SetPrice(tempInt);

  cout << "Enter the item quantity:" << endl;
  cin >> tempInt;
  item2.SetQuantity(tempInt);

  cout << endl;
  item1.PrintTotalCost(item1, item2);
  */
  /*
  ShoppingCart cart1;
  ItemToPurchase chocolate{"chocolate", "sweet", 1, 4};
  ItemToPurchase milk{"milk", "salty", 3, 1};
  ItemToPurchase eggs{"eggs", "sweet", 1, 6};
  ItemToPurchase bread{"bread", "sweet", 5, 1};

  cart1.AddItem(chocolate);
  cart1.AddItem(milk);
  cart1.AddItem(eggs);
  cart1.AddItem(bread);
  */

  string customerName, date;

  cout << "Enter customer's name:" << endl;
  getline(cin, customerName);
  cout << "Enter the today's date:" << endl;
  getline(cin, date);
  cout << endl;
  cout << "Customer name: " << customerName << endl;
  cout << "Today's date: " << date << endl;

  return 0;
}
Fetching token
?