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