Header Ads

Imagine a Publishing Company that Markets Both Book and Audio Cassette | Publication Class Tape Class Book Class

 

Imagine a Publishing Company that make Book and Audio Cassette. Create Class Publication that store the Price (Type Float) of a Publication. 

From this Class Drive Two Classes BOOK which adds a Page Count (type int) and TAPE which adds a Playing Time in Minutes (Type Float). 

Each of these Three Classes should Have a GetData() Function to Get Its Data from the user at the Keyboard and a PutData() Function to Display its data object.

 Write a Main Program to test Book and TAPE Classes by Creating Objects of Them and Then Display the Data

Program Source Code

#include<iostream>

using namespace std;

class publication{

protected:

    float price;

public:

publication():price(0.0){

}

void getData(){

cout<<"Enter Price:";

cin>>price;

}

void putData(){

cout<<"Price :"<<price<<endl;

}

};

class Book : public publication{

private:

int pageCount;

public:

Book():pageCount(0){

}

void getData(){

cout<<"Enter Book Page:";

cin>>pageCount;

publication::getData();

}

void putData(){

cout<<"Book Page :"<<pageCount<<endl;

publication::putData();

}

};

class TAPE : public publication{

private:

float time;

public:

TAPE():time(0.0){

}

void getData(){

cout<<"Enter Tape Time in minits:";

cin>>time;

publication::getData();

}

void putData(){

cout<<"Time :"<<time<<endl;

publication::putData();

}

};

main(){

Book b;

TAPE t;

int op;

char choice;

do{

system("cls");

cout<<"1.Book Information"<<endl;

cout<<"2.TAPE Information"<<endl;

cout<<"---------------------"<<endl;

cout<<"Enter Your Choice :";

cin>>op;

switch(op){

case 1:

cout<<"--------Book Information------"<<endl;

b.getData();

        b.putData();

    break;

    case 2:

    cout<<"--------TAPE Information------"<<endl;

    t.getData();

t.putData();

   

break;

}

cout<<"Do You Want to Continue or Exit [Y/N] ?";

cin>>choice;

}while(choice=='y'||choice=='Y');

}





Related Video




No comments

Powered by Blogger.