Advertisement

CS304 assignment 3 solution 2021

Please downlaod .CPP file link available at the end of the page. 

#include <iostream>
#include <string>
using namespace std;

class StackItem{
private:
string ItemName;
string Course_Code;
string Course_Name;
int Price;
int Quantity;

public:
Stackitem()
{

}
void setItemName()
{
cout<<“\nPlease enter the name of item : “;
cin>>ItemName;
}

void setCourse_Code()
{
cout<<“\nPlease enter the course code : “;
cin>> Course_Code;
}

void setCourse_Name()
{
cout<<“\nPlease Enter the course name : “;
cin>> Course_Name;
}

void setPrice()
{
cout<<“\nPlease enter the item price : “;
cin>> Price;
}
void setQuantity()
{

cout<<“\nPlease enter the quantity of item : “;
cin>> Quantity;
}
string getItemName()
{
return ItemName;
}

string getCourse_Code()
{
return Course_Code;
}

string getCourse_Name()
{
return Course_Name;
}

int getPrice()
{
return Price;
}

int getQuantity()
{
return Quantity;
}

void display()
{

}

};
class Lecture_DVD:public StackItem{
private:
int TotalMins;
int TotalLec;
public:
Lecture_DVD()
{

}

void setTotalMins()
{
cout<<“\nPlease enter the total minutes of the vedio : “;
cin>>TotalMins;
}

void setTotalLec()
{
cout<<“\nPlease enter the total lectures : “;
cin>>TotalLec;
}

int getTotalMins()
{
return TotalMins;
}

int getTotalLec()
{
return TotalLec;
}
virtual void display()
{
cout<<“\nDisplaying Lecture DVD Information:”<<endl;
cout<<“………………………………….\n”;
cout<<“Item Name: “<<getItemName()<<endl;
cout<<“Course Name: “<<getCourse_Name()<<endl;
cout<<“Course Code: “<<getCourse_Code()<<endl;
cout<<“Quantity: “<<getQuantity()<<endl;
cout<<“Price: “<<getPrice()<<endl;
cout<<“Minutes: “<<getTotalMins()<<endl;
cout<<“Lectures: “<<getTotalLec()<<endl;
}

};

class Handouts:public StackItem{

private:
int No_Pages;
string Author;
public:
Handout()
{

}

void setNo_Pages()
{
cout<<“\nPlease enter Pages : “;
cin>> No_Pages;
}

Advertisement

void setAuthor()
{
cout<<“\nPlease enter the author : “;
cin>> Author;
}
int getNo_Pages()
{
return No_Pages;
}
string getAuthor()
{
return Author;
}
virtual void display()
{
cout<<“\nDisplaying Book Information:”<<endl;
cout<<“………………………………….\n”;
cout<<“Item Name: “<<getItemName()<<endl;
cout<<“Course Name: “<<getCourse_Name()<<endl;
cout<<“Course Code: “<<getCourse_Code()<<endl;
cout<<“Handout Quantity: “<<getQuantity()<<endl;
cout<<“Handout Price: “<<getPrice()<<endl;
cout<<“Handout Pages: “<<getNo_Pages()<<endl;
cout<<“Handout Author: “<<getAuthor()<<endl;
}
};

int main()

{
int size, i;
char arr[size], check;
Handouts handouts;
Lecture_DVD lecture_dvd;
cout<<“\nHow many items do you want to enter? “<<endl;
cin>>size;
while(i<size)
{

cout<<“\nEnter choice: H for Handouts, L for Lecture DVD: “<<endl;
cin>>arr[i];
if(arr[i] == ‘H’ || arr[i] == ‘h’)
{

cout<<“\nEnter following data for Handouts: “<<endl;
handouts.setItemName();
handouts.setQuantity();
handouts.setPrice();
handouts.setCourse_Name();
handouts.setCourse_Code();
handouts.setNo_Pages();
handouts.setAuthor();
}
if(arr[i]==’l’ || arr[i]== ‘L’ )
{

cout<<“\nEnter following data for Lecture DVD: “<<endl;
lecture_dvd.setItemName();
lecture_dvd.setQuantity();
lecture_dvd.setPrice();
lecture_dvd.setCourse_Name();
lecture_dvd.setCourse_Code();
lecture_dvd.setTotalMins();
lecture_dvd.setTotalLec();
}
cout<<“\nDo you want to enter more data (Y for yes, N for No): “;
cin>>check;
if(check==’n’ || check ==’N’ || i==size-1)
{
for (i=0; i<size; i++)
{

if(arr[i] ==’H’ || arr[i] == ‘h’)
{
handouts.display();

}
if(arr[i] == ‘L’ || arr[i] == ‘l’)
{
lecture_dvd.display();

}
}
}
i++;

}
}

CS304 assignment 3 solution 2021

Downlaod solution file

Leave a comment