office.cpp (1906B)
1 #include "office.hpp" 2 3 Office::Office() :App() {} 4 5 Office::Office(const char *serialnum, const std::string& name, 6 const std::string& os, Manufacturer *manf, 7 const int price, const std::vector<std::string>& ext) 8 :App(serialnum, name, os, manf, price), extensions(ext) {} 9 10 Office::Office(const Office& of) 11 :App(of.serialnum, of.name, of.os, of.manf, of.price), 12 extensions(of.extensions) {} 13 14 Office::~Office() 15 { 16 if (!extensions.empty()) extensions.clear(); 17 } 18 19 void 20 Office::set_exts(const std::vector<std::string>& extensions) 21 { 22 if (!this->extensions.empty()) this->extensions.clear(); 23 this->extensions = extensions; 24 } 25 26 void 27 Office::print(std::ostream& stream) const 28 { 29 stream << 30 std::left << std::setw(7) << serialnum << 31 std::left << std::setw(20) << name << 32 std::left << std::setw(20) << os << 33 std::left << std::setw(7) << price; 34 35 stream << 36 std::left << std::setw(7) << manf->get_serialnum() << 37 std::left << std::setw(15) << manf->get_name() << 38 std::left << std::setw(25) << manf->get_email(); 39 40 stream << 41 std::left << std::setw(10) << "N/A" << 42 std::left << std::setw(10) << "N/A"; 43 44 for (auto& ext : extensions) 45 stream << ext << " "; 46 47 std::vector<Review *> revs = get_revs(); 48 if (!reviews.empty()) 49 { 50 stream << std::endl << std::endl << std::left << "Reviews:" << std::endl; 51 stream << 52 std::left << std::setw(7) << "Stars" << 53 std::left << std::setw(25) << "Username" << 54 std::left << "Comment" << std::endl << std::endl; 55 56 for (auto& rev : reviews) 57 stream << 58 std::left << std::setw(7) << rev->get_stars() << 59 std::left << std::setw(25) << rev->get_username() << 60 std::left << rev->get_comment() << std::endl; 61 } 62 stream << std::endl; 63 }