#include<iostream>
using namespace std;

class Publication{
  protected:
    char tittle[30];
    float price;
  public: 
    virtual void getData(){
    }   
    virtual void putData(){     
    }           
};
class Book: public Publication{
  private:
     int pages;
  public:
     void getData(){
        cout<<"Enter Book Tittle : ";
        cin>>tittle;
        cout<<"Enter Price      : ";
        cin>>price;
        cout<<"Enter total pages : ";
        cin>>pages;     
     }
     void putData(){
        cout<<"========================="<<endl;  
        cout<<"Book Tittle: "<<tittle<<endl;
        cout<<"     Price : "<<price<<endl;     
        cout<<"Total Pages: "<<pages<<endl;
        cout<<"========================="<<endl;
     }        
};
class Tape: public Publication{
  private:
     int duration;
  public:
     void getData(){
        cout<<"Enter Tape Tittle : ";
        cin>>tittle;
        cout<<"Enter Price      : ";
        cin>>price;
        cout<<"Enter Duration    : ";
        cin>>duration;     
     }
     void putData(){
        cout<<"========================="<<endl;  
        cout<<"Tape Tittle: "<<tittle<<endl;
        cout<<"     Price : "<<price<<endl;     
        cout<<"  Duration : "<<duration<<endl;
        cout<<"========================="<<endl;
     }        
};
main(){
   char choice='y', r_choice;
   Publication* ptr[100];
   int count=0;
      
   do{
     cout<<"Do you want to enter Book ot Tape record (B/T) : ";
     cin>> r_choice;
     if(r_choice == 'B' || r_choice == 'b')
        ptr[count] = new Book;
     else if(r_choice == 'T' || r_choice == 't')          
             ptr[count] = new Tape;
     else{
        cout<<"enter correct choice "<<endl;
        continue;        
     }
     ptr[count]->getData();
     count++;
     cout<<"Do you want to another record (Y/N) : ";
     cin>>choice;
   }while(choice == 'y' || choice == 'Y');  
   
   for(int n=0; n<count; n++){
      ptr[n]->putData();        
   }     
   system("pause");       
}
