Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Practical 3:
- // @author xCircle (Pranav)
- #include<bits/stdc++.h>
- using namespace std;
- class Publication
- {
- public:
- string title;
- float price;
- void update()
- {
- cout<<"Enter the Title of the book : ";
- cin>>title;
- cout<<"\nEnter the price of : ";
- cin>>price;
- if(price==0)
- {
- throw int(price);
- }
- }
- void publish()
- {
- cout<<"\nBook:- "<<title<<"\nPrice:- Rs"<<price;
- }
- };
- class Book : public Publication
- {
- public:
- int pageCount;
- void getData()
- {
- cout<<"\nEnter the No. of pages : ";
- cin>>pageCount;
- if(pageCount==0)
- {
- throw pageCount;
- }
- }
- void putData()
- {
- cout<<"\nPages:- "<<pageCount;
- }
- };
- class Tape : public Publication
- {
- public:
- float playTime;
- void getData()
- {
- cout<<"\nEnter the play time in minuites : ";
- cin>>playTime;
- if(playTime==0)
- {
- throw int(playTime);
- }
- }
- void putData()
- {
- cout<<"\nPlay Time:- "<<playTime<<"min";
- }
- };
- int main()
- {
- Book b1;
- Tape t1;
- try{
- b1.update();
- b1.getData();
- t1.getData();
- }
- catch(int e)
- {
- cout<<"*Error* \nException Caught";
- b1.title="0";
- b1.price=0;
- b1.pageCount=0;
- t1.playTime=0;
- }
- b1.publish();
- b1.putData();
- t1.putData();
- }
Advertisement
Add Comment
Please, Sign In to add comment