Q:

Choose one of the following abstractions (or an abstraction of your own choosing)

0

Choose one of the following abstractions (or an abstraction of your own choosing).  Determine what data are needed in the class. Provide an appropriate set of constructors. Explain your decisions.

(a) Book

(b) Date

(c) Employee

(d) Vehicle

(e) Object

(f) Tree

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

(a) Book

class Book {
    public:
      Book() : isbn(""), name(""), author(),
          publish_year(0), publisher(""), version(0) {}
      Book(const std::string &i, const std::string &n,
           const std::vector<std::string> &au,
           unsigned y, const std::string &p = "", unsigned v = 1)
          : isbn(i), name(n), author(au),
            publish_year(y), publisher(p), version(v) {}
      Book(std::istream &is) {
        is >> isbn >> name;
        std::string s;
        is >> s;
        author.push_back(s);
        is >> publish_year >> publisher >> version;
      }

    private:
      std::string isbn;
      std::string name;
      std::vector<std::string> author;
      unsigned publish_year;
      std::string publisher;
      unsigned version;
    };

(b) Date

(c) Employee

(d) Vehicle

(e) Object

(f) Tree

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now