app.hpp (1715B)
1 #ifndef APP_HPP 2 #define APP_HPP 3 4 #include <cstring> 5 #include <iomanip> 6 #include <iostream> 7 #include <stdexcept> 8 #include <string> 9 #include <vector> 10 11 #include "errlog.hpp" 12 #include "manufacturer.hpp" 13 #include "review.hpp" 14 15 class App 16 { 17 protected: 18 const char *serialnum; 19 std::string name; 20 std::string os; 21 Manufacturer *manf; 22 std::vector<Review *> reviews; 23 int price; 24 ErrLog errlog; 25 26 public: 27 App(); 28 App(const char *serialnum, const std::string& name, 29 const std::string& os, Manufacturer *manf, const int price); 30 App(const App& app); 31 virtual ~App(); 32 33 void addrev(Review *rev) {reviews.push_back(rev);} 34 void addrevs(const std::vector<Review *> revs) 35 {reviews.insert(reviews.end(), revs.begin(), revs.end());} 36 37 const std::string& get_name() const {return name;} 38 const std::string& get_os() const {return os;} 39 constexpr const Manufacturer& get_manf() const {return *manf;} 40 constexpr const char *get_serialnum() const {return serialnum;} 41 constexpr const std::vector<Review *>& get_revs() const {return reviews;} 42 constexpr const int get_price() const {return price;} 43 44 void set_serialnum(const char *serialnum); 45 void set_name(const std::string& name) {this->name = name;} 46 void set_os(const std::string& os) {this->os = os;} 47 void set_manf(Manufacturer *manf) {this->manf = manf;} 48 void set_price(const int price) {this->price = price;} 49 50 virtual void print(std::ostream& stream) const = 0; 51 52 private: 53 char *convsn(const char *serialnum); 54 }; 55 56 #endif /* APP_HPP */