Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iomanip>
- #include <iostream>
- #include <vector>
- #include <string>
- using namespace std;
- class Toy
- {
- int artticle;
- int price;
- int handmade;
- int logs;
- string material;
- public:
- Toy(){artticle=0; price=99; material="synthetics"; handmade=0; logs=0;}
- int get_price()
- {
- return price;
- }
- int get_price_by_article(int x)
- {
- if (artticle==x)
- {
- return price;
- }
- }
- void handmade_toy(string a)
- {
- artticle=3;
- material=a;
- if (a=="synthetics") price=599;
- if (a=="cotton") price=699;
- if (a=="wool") price=799;
- if (a!="synthetics" && a!="cotton" && a!="wool") price=999;
- if (logs==1)
- {
- cout << "CREATED " << artticle <<" " << material << " " << price << endl;
- }
- }
- void make_toy_by_article(int x)
- {
- artticle=x;
- if (x==1)
- {
- material="cotton";
- price=199;
- }
- if (x==2)
- {
- material="wool";
- price=299;
- }
- if (logs==1)
- {
- cout << "CREATED " << artticle <<" " << material << " " << price << endl;
- }
- }
- string get_material()
- {
- return material;
- }
- };
- int main() {
- int n=0;
- string cmd;
- cin >> n;
- vector<Toy> toys(1000);
- int sum = 0;
- int k=0;
- int junk1=0,junk2=0;
- for (int i=0; i<n; i++)
- {
- cin >> cmd;
- if (cmd =="hand")
- {
- cin >> cmd;
- toys[k].handmade_toy(cmd);
- k++;
- }
- if (cmd=="machine")
- {
- cin >> junk1>>junk2;
- for (int j=0; j<junk2; j++)
- {
- toys[k].make_toy_by_article(junk1);
- k++;
- }
- }
- }
- cin >> junk1;
- for (int i=0; i<k; i++)
- {
- sum+=toys[i].get_price_by_article(junk1);
- }
- cout << sum;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement