Guest User

Untitled

a guest
Oct 1st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class InventoryItem
  7. {
  8. private:
  9.     int stockNum;
  10.     double price;
  11. public:
  12.     void setStockNum(int);
  13.     void setPrice(double);
  14.     void display();
  15. };
  16.  
  17. void InventoryItem::setStockNum(int stkNum)
  18. {
  19.     stockNum = stkNum;
  20. }
  21.  
  22. void InventoryItem::setPrice(double pr)
  23. {
  24.     price = pr;
  25. }
  26.  
  27. void InventoryItem::display()
  28. {
  29.     cout << "Item #" << stockNum << " costs $" << price << endl;
  30. }
  31.  
  32.  
  33. class Salesperson
  34. {
  35. private:
  36.     int idNum;
  37.     string name;
  38. public:
  39.     void setIdNum(int);
  40.     void setName(string);
  41.     void display();
  42. };
  43.  
  44. void Salesperson::setIdNum(int id)
  45. {
  46.     idNum = id;
  47. }
  48.  
  49. void Salesperson::setName(string lastName)
  50. {
  51.     name = lastName;
  52. }
  53.  
  54. void Salesperson::display()
  55. {
  56.     cout << "Salesperson #" << idNum << " " << name << endl;
  57. }
  58.  
  59. class Transaction
  60. {
  61. private:
  62.     int transNum;
  63.     InventoryItem itemSold;
  64.     Salesperson seller;
  65. public:
  66.     Transaction(int, int, double, int, string);
  67.     void display();
  68. };
  69.  
  70. Transaction::Transaction(int num, int item, double pr, int salesID, string name)
  71. {
  72.     transNum = num;
  73.     itemSold.setNum(item);
  74.     itemSold.setPrice(pr);
  75.     seller.setId(salesID);
  76.     seller.setName(name);
  77. }
  78.  
  79. void Transaction::display()
  80. {
  81.     cout << "Data for transaction #" << transNum << endl;
  82.     itemSold.displayItem();
  83.     seller.displayPerson();
  84. }
  85.  
  86.  
  87. void main()
  88. {
  89.     Transaction aSale(1533, 988, 22.95, 312, "Patterson");
  90.     aSale.display();
  91.  
  92.  
  93.     system("pause");
  94. }
Advertisement
Add Comment
Please, Sign In to add comment