Subscribe Us

Responsive Advertisement

Advertisement

E.balagurusamy 6.4 oop solution

 

E.balagurusamy 6.4 oop solution

 by ujjal roy



#include<bits/stdc++.h>

using namespace std;

class book_shop

{

    string *author;

    string *title;

    double *price;

    string *publisher;

    int *copys;

   static int succ;

   static int uss;


   friend void update_price(book_shop &b);


public :

      book_shop(string title1)

     {

         author=new string[5];

         title=new string[5];

         price=new double[5];

         publisher=new string[5];

         copys=new int[5];

             author[0]="balaguru";

             title[0]="ANSIC";

             price[0]=500;

             publisher[0]="alpha";

             copys[0]=50;

             author[1]="balaguru";

             title[1]="OPP";

             price[1]=500;

             publisher[1]="alpha";

             copys[1]=50;

             author[2]="balaguru";

             title[2]="exercise";

             price[2]=500;

             publisher[2]="alpha";

             copys[2]=50;

             author[3]="kaykobad";

             title[3]="c_progrmming";

             price[3]=500;

             publisher[3]="alpha";

             copys[3]=50;

             author[4]="subin";

             title[4]="C";

             price[4]=500;

             publisher[4]="alpha";

             copys[4]=50;




     }

    void create(string title1 , string author1)

    {

        int c=0,i,p;

       for(i=0;i<5;i++)

       {

           if(title1==title[i]&&author1==author[i])

           {

               c=1;

               p=i;

               break;

           }


       }

         if(c)

           {

             cout<<"author : "<<author[p]<<"\ntitle :"<<title[p]<<endl;

             cout<<"price : "<<price[p]<<"\npublisher :"<<publisher[p]<<endl;

             cout<<"available : "<<copys[p]<<endl;

             cout<<"\nHow many copys you want : ";

             int co;

             cin>>co;

             if(co<=copys[p])

             {

                 double total=co*price[p];

                 cout<<"total price : "<<total<<endl;

                 copys[p]-=co;

                 succ++;

             }

             else cout<<"sorry.out of stoke\n";

           }

           else

           {

               cout<<"Not found\n";

           }

    }



   void show_history()

   {

       cout<<"successfully  transsaction : "<<succ<<endl;

        cout<<"unsuccessfully  transsaction : "<<uss<<endl;

   }

};

int book_shop ::uss;

int book_shop ::succ;

void update_price(book_shop &b)

{

   string s,s1;

   cout<<"enter title :";

   cin>>s;

   cout<<"enter author :";

   cin>>s1;

     cout<<"Enter update price : ";

   double pr;

   cin>>pr;

     int c=0,i,p;

       for(i=0;i<5;i++)

       {

           if(s==b.title[i]&&s1==b.author[i])

           {

               c=1;

               p=i;

               break;

           }


       }

       if(c)

       {

           b.price[p]=pr;

           cout<<"price update successfully\n";

       }

       else cout<<"NOT found\n";


}

int main()

{


   string s,s1;

   cout<<"enter title :";

   cin>>s;

   cout<<"enter author :";

   cin>>s1;

     book_shop bs(s);

   bs.create(s,s1);

   update_price(bs);

   bs.create(s,s1);

   bs.show_history();

    return 0;

}


Post a Comment

0 Comments