123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- //
- // Created by jovian on 20/08/17.
- //
- #ifndef SPACEEXPANSION_STOCK_H
- #define SPACEEXPANSION_STOCK_H
- #include <array>
- #define RESOURCE_NUMBER 8
- enum Resource {
- PEOPLE,
- ORE,
- METAL,
- ENERGY,
- NUCLEAR_ORE,
- SOLAR_PANELS,
- RADIOACTIVITY,
- METAL_INDUSTRY,
- SOLAR_INDUSTRY,
- NUCLEAR_INDUSTRY,
- SHIP_INDUSTRY,
- SHIP_PROGRESS
- };
- class Stock {
- // Methods
- public:
- Stock();
- // todo Copy constructor
- int set(Resource res, int val); // Replace value and return the previous one
- int add(Resource res, int val); // Add value and return total
- int get(Resource res) const; // Read a value
- void setZero(); // Set every value to zero
- void setPositive(); // Set negative values to zero
- Resource mostResource() const; // Return the most present resource
- Stock &operator+=(Stock const &stock);
- Stock &operator-=(Stock const &stock);
- Stock &operator*=(int const &multi);
- Stock &operator/=(int const &multi);
- // Attributes
- private:
- std::array<int, RESOURCE_NUMBER> m_tab;
- };
- Stock operator+(Stock const &a, Stock const &b);
- Stock operator-(Stock const &a, Stock const &b);
- Stock operator*(Stock const &a, int const &b);
- Stock operator/(Stock const &a, int const &b);
- #endif //SPACEEXPANSION_STOCK_H
|