uni

University stuff
git clone git://git.christosmarg.xyz/uni-assignments.git
Log | Files | Refs | README | LICENSE

game.cpp (1725B)


      1 #include "game.hpp"
      2 
      3 Game::Game()
      4     :App(), genre(""), online(false) {}
      5 
      6 Game::Game(const char *serialnum, const std::string& name,
      7         const std::string& os, Manufacturer *manf, const int price,
      8         const std::string& genre, const bool online)
      9     :App(serialnum, name, os, manf, price), genre(genre), online(online)
     10 {
     11     if (genre.empty())
     12         errlog.write("Game: " + std::string(serialnum) + ": Empty genre");
     13 }
     14 
     15 Game::Game(const Game& g)
     16     :App(g.serialnum, g.name, g.os, g.manf, g.price), genre(g.genre),
     17     online(g.online) {}
     18 
     19 void
     20 Game::print(std::ostream& stream) const
     21 {
     22     stream <<
     23         std::left << std::setw(7) << serialnum <<
     24         std::left << std::setw(20) << name <<
     25         std::left << std::setw(20) << os <<
     26         std::left << std::setw(7) << price;
     27 
     28     stream <<
     29         std::left << std::setw(7) << manf->get_serialnum() <<
     30         std::left << std::setw(15) << manf->get_name() <<
     31         std::left << std::setw(25) << manf->get_email();
     32 
     33     stream <<
     34         std::left << std::setw(10) << genre <<
     35         std::left << std::setw(10) << (online ? "Yes" : "No");
     36     stream << "N/A";
     37 
     38     if (!reviews.empty())
     39     {
     40         stream << std::endl << std::endl << std::left << "Reviews:" << std::endl;
     41         stream << 
     42             std::left << std::setw(7) << "Stars" <<
     43             std::left << std::setw(25) << "Username" <<
     44             std::left << "Comment" << std::endl << std::endl;
     45 
     46         for (auto& rev : reviews)
     47             stream <<
     48                 std::left << std::setw(7) << rev->get_stars() <<
     49                 std::left << std::setw(25) << rev->get_username() <<
     50                 std::left << rev->get_comment() << std::endl;
     51     }
     52     stream << std::endl;
     53 }