Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CreditAccount
- {
- private:
- public:
- int credits = 0;
- double bools_rate = 0;
- double stars_rate = 0;
- double borks_rate = 0;
- public:
- void prepare() { std::cin >> credits >> stars_rate >> bools_rate >> borks_rate; }
- void buy(int t_credits) { credits -= t_credits; } // m_credits = m_credits > 0 ? m_credits : 0;
- void putCredits(int t_credits) { credits += t_credits; }
- void putProtorianBools(int t_bools) { credits += t_bools * bools_rate; }
- void putOrionStars(int t_stars) { credits += t_stars * stars_rate; }
- void putOmegaSectorBorks(int t_borks) { credits += t_borks * borks_rate; }
- std::string printStatus() { return "Account: " + std::to_string(credits) + " credits"; }
- };
- class SpacePoint
- {
- private:
- int X, Y;
- public:
- SpacePoint()
- :X(0), Y(0) {}
- SpacePoint(int t_X, int t_Y)
- :X(t_X), Y(t_Y) {}
- void read() { std::cin >> X >> Y; }
- int distance(const SpacePoint other) { return sqrt(pow(X - other.X, 2) + pow(Y - other.Y, 2)); }
- int get_x() { return X; }
- int get_y() { return Y; }
- };
- class SpaceShip
- {
- private:
- std::string name;
- int fuelLeft;
- int fuelMax;
- SpacePoint position;
- public:
- CreditAccount account;
- CreditAccount& get_credits() { return account; }
- void printStatus()
- {
- std::cout << "STATUS: " << name
- << "\nCordinates: x=" << position.get_x() << " y=" << position.get_y()
- << "\nFuel: " << fuelLeft << " from " << fuelMax
- << "\n" << account.printStatus() << "\n";
- }
- void flight(SpacePoint p)
- {
- fuelLeft -= position.distance(p);
- if (fuelLeft < 0) fuelLeft = 0;
- position = p;
- }
- void prepare()
- {
- std::cin >> name >> fuelLeft >> fuelMax;
- position.read();
- account.prepare();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement