Stock.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // Created by jovian on 20/08/17.
  3. //
  4. #ifndef SPACEEXPANSION_STOCK_H
  5. #define SPACEEXPANSION_STOCK_H
  6. #include <array>
  7. #define RESOURCE_NUMBER 8
  8. enum Resource {
  9. PEOPLE,
  10. ORE,
  11. METAL,
  12. ENERGY,
  13. NUCLEAR_ORE,
  14. SOLAR_PANELS,
  15. RADIOACTIVITY,
  16. METAL_INDUSTRY,
  17. SOLAR_INDUSTRY,
  18. NUCLEAR_INDUSTRY,
  19. SHIP_INDUSTRY,
  20. SHIP_PROGRESS
  21. };
  22. class Stock {
  23. // Methods
  24. public:
  25. Stock();
  26. // todo Copy constructor
  27. int set(Resource res, int val); // Replace value and return the previous one
  28. int add(Resource res, int val); // Add value and return total
  29. int get(Resource res) const; // Read a value
  30. void setZero(); // Set every value to zero
  31. void setPositive(); // Set negative values to zero
  32. Resource mostResource() const; // Return the most present resource
  33. Stock &operator+=(Stock const &stock);
  34. Stock &operator-=(Stock const &stock);
  35. Stock &operator*=(int const &multi);
  36. Stock &operator/=(int const &multi);
  37. // Attributes
  38. private:
  39. std::array<int, RESOURCE_NUMBER> m_tab;
  40. };
  41. Stock operator+(Stock const &a, Stock const &b);
  42. Stock operator-(Stock const &a, Stock const &b);
  43. Stock operator*(Stock const &a, int const &b);
  44. Stock operator/(Stock const &a, int const &b);
  45. #endif //SPACEEXPANSION_STOCK_H