fork download
  1. #include<iostream>
  2. #include<vector>
  3. #include<map>
  4. using namespace std;
  5.  
  6. class Product {
  7. public:
  8. int productID;
  9. string productName;
  10. double productPrice;
  11.  
  12. Product(int id, string name, double price) {
  13. productID = id;
  14. productName = name;
  15. productPrice = price;
  16. }
  17.  
  18. };
  19.  
  20. class Customer{
  21. public:
  22. string name;
  23. string mobile;
  24. bool local;
  25.  
  26. Customer(){}
  27.  
  28. Customer(string n, string m, bool l){
  29. name=n;
  30. mobile=m;
  31. local=l;
  32. }
  33. };
  34.  
  35.  
  36. class Order{
  37. public:
  38. string orderId;
  39. double price;
  40. Customer c;
  41.  
  42. Order(string id, double p, Customer cr){
  43. orderId=id; price=p; c=cr;
  44. }
  45. };
  46.  
  47.  
  48.  
  49. class Supermarket{
  50. public:
  51. vector<Product>p;
  52. vector<Order>o;
  53.  
  54. Supermarket(vector<Product>pr, vector<Order>ord){
  55. p=pr, o=ord;
  56. }
  57.  
  58. void addProduct(Product pr){
  59. p.push_back(pr);
  60. }
  61.  
  62. void addOrder(Order ord){
  63. o.push_back(ord);
  64. }
  65. };
  66.  
  67. class GroceryStore: public Supermarket{
  68. public:
  69. double discount;
  70.  
  71. GroceryStore(vector<Product>pr, vector<Order>ord): Supermarket(pr, ord)
  72. {
  73. discount=0.02;
  74. }
  75.  
  76. void addOrder(Order ord){
  77. if(ord.c.local==true){
  78. ord.price-=ord.price*discount;
  79. }
  80. o.push_back(ord);
  81. }
  82. };
  83.  
  84.  
  85. int main(){
  86. return 0;
  87. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty