Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ language Using classes (OOD), design a system that will support lending vari

ID: 3795298 • Letter: C

Question

C++ language

Using classes (OOD), design a system that will support lending various types of media starting with books. Program should be able to handle a maximum of 500 books. Program should meet at least the following requirements:

1. Define a base media class with a book class derived from it. (Specific class names determined by programmer.)

2. The classes should contain at least the following information: title, up to four authors, ISBN.

3. Define a collection class that will hold up to 500 books.

4. The program should be able to perform the following operations supported by the class definitions:

a) Load data from a drive

b)Sort and display the books by title

c)Sort and display the books by author

d)Add and remove books

Programming requirements: Must include examples of inheritance and composition

~~~Function/Class comments (Description, pre and post conditions)

~~~Internal comments for all functions

Explanation / Answer

#include <iostream>

#include <cstring>

using namespace std;

class media

{

   protected:

      character title[50];

      float ISBN;

                              

   public:

      media( char * s, float a)

     {

         Strcpy(title, s);

         ISBN = a;

      }

      Virtual void display() {}

};

                              

class book: public media

{

int pages;

   public:

            book ( char * s, float a, int p) : media(s,a)

               {

               pages = p;

               }

               void display();

};

class dvd: public media

{

Float time;

   public:

            dvd ( char * s, float a, float t) : media(s,a)

               {

               time = t;

               }

               void display();

};

Void book :: display()

{

cout << “ Title: “ << title;

cout << “ Pages: “ << pages;

cout << “ ISBN: “ << ISBN;

}

Void dvd :: display()

{

cout << “ Title: “ << title;

cout << “ Play time: “ << time;

cout << “ Price: “ << price;

}

// Main function for the program

int main( )

{

Char * title = new char[30] ;

  Float price, time;

Int pages;

//Book Details

  cout << “ Enter book details ”;

cout << “ Title: “; cin>> title;

cout << “ ISBN: “ <; cin>> ISBN;

cout << “ Pages: “; cin>> pages;

book book1 (title, ISBN, pages);

//Dvd Details

  cout << “ Enter dvd details ”;

cout << “ Title: “; cin>> title;

cout << “ Play time: “; cin>> time;

  cout << “ Price: “ <; cin>> price;

tape tape1 (title, price, time);

media * list[2];

list[0] = &book1;

list[1] = &dvd1;

cout << “ BOOK”;

list[0] -> display();

cout << “ Dvd”;

list[1] -> display();

   return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote