Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. #include <iomanip>
  2. #include <iostream>
  3. #include <vector>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. class Toy
  9. {
  10. int artticle;
  11. int price;
  12. int handmade;
  13. int logs;
  14. string material;
  15. public:
  16. Toy(){artticle=0; price=99; material="synthetics"; handmade=0; logs=0;}
  17. int get_price()
  18. {
  19. return price;
  20. }
  21. int get_price_by_article(int x)
  22. {
  23. if (artticle==x)
  24. {
  25. return price;
  26. }
  27. }
  28.  
  29. void handmade_toy(string a)
  30. {
  31. artticle=3;
  32. material=a;
  33. if (a=="synthetics") price=599;
  34. if (a=="cotton") price=699;
  35. if (a=="wool") price=799;
  36. if (a!="synthetics" && a!="cotton" && a!="wool") price=999;
  37. if (logs==1)
  38. {
  39. cout << "CREATED " << artticle <<" " << material << " " << price << endl;
  40. }
  41. }
  42.  
  43. void make_toy_by_article(int x)
  44. {
  45. artticle=x;
  46. if (x==1)
  47. {
  48. material="cotton";
  49. price=199;
  50. }
  51. if (x==2)
  52. {
  53. material="wool";
  54. price=299;
  55. }
  56. if (logs==1)
  57. {
  58. cout << "CREATED " << artticle <<" " << material << " " << price << endl;
  59. }
  60. }
  61. string get_material()
  62. {
  63. return material;
  64. }
  65.  
  66. };
  67.  
  68. int main() {
  69. int n=0;
  70. string cmd;
  71. cin >> n;
  72. vector<Toy> toys(1000);
  73. int sum = 0;
  74. int k=0;
  75. int junk1=0,junk2=0;
  76. for (int i=0; i<n; i++)
  77. {
  78. cin >> cmd;
  79. if (cmd =="hand")
  80. {
  81. cin >> cmd;
  82. toys[k].handmade_toy(cmd);
  83. k++;
  84. }
  85. if (cmd=="machine")
  86. {
  87. cin >> junk1>>junk2;
  88. for (int j=0; j<junk2; j++)
  89. {
  90. toys[k].make_toy_by_article(junk1);
  91. k++;
  92. }
  93. }
  94.  
  95. }
  96. cin >> junk1;
  97. for (int i=0; i<k; i++)
  98. {
  99. sum+=toys[i].get_price_by_article(junk1);
  100. }
  101. cout << sum;
  102. return 0;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement