Page 455 - C++
P. 455

code[serial]=temp;
                   cout<<"\n Enter name of item:";
                   gets(name[serial]);
                   cout<<"\n Enter price:Rs. ";
                   cin>>price[serial];
                   serial++;
                   cout<<"\n\t Do you want to add/replace more items?(press y/any other
                key):";
                   choice=getch();}while(choice=='y'||choice=='Y');
                }

                       //Fn for displaying menu
                void item::display()
                {
                 clrscr();
                 cout<<"\n\t\t\tMENU!";
                 cout<<"\n\n S.no.\tCode\t\t\tName\t\t\tPrice(Rs.)";
                 for(serial=0;name[serial][0]!='\0';serial++)
                     {cout<<"\n "<<serial+1<<"\t"<<code[serial]<<"\t\t";
                     cout.width(16);
                     cout<<name[serial];
                     cout<<"\t\t  "<<price[serial];}
                }

                       //Fn for editing inventory
                void item::edit()
                {char choice,choice1;
                 int temp;
                 do{clrscr();
                    cout<<"\n\t\t\tEdit!";
                    cout<<"\n\n What do you want to edit?\n\n(1)Name of item\n\n(2)Price
                of item\n\n(3)Item code\n\n(4)Exit to item's screen\n\n\t\t Your
                choice(1-4):";
                    choice=getch();
                    switch(choice)
                         {case '1': do{clrscr();
                                   cout<<"\n\t\t\tChange name!\n\n Enter the code you want
                to change the name for:";
                                   cin>>temp;
                                   for(int i=0;name[i][0]!='\0'&&code[i]!=temp&&i<no;i++);
                                       if(code[i]==temp)
                                         {cout<<"\n Enter the new name for item:";
                                          gets(name[i]);
                                          cout<<"\n\t\t\t Name changed sucessfully!";}
                                   else
                                       cout<<"\n\n\t\t\t\a Code not found!";
                                   cout<<"\n\n\tDo you want to change name of another
                item?(press y/any other key):";
                                   choice1=getch();}while(choice1=='y'||choice1=='Y');
                                   break;
                          case '2':do{clrscr();
                                   cout<<"\n\t\t\tChange price!\n\n Enter the code you want
                to change the price for:";
                                   cin>>temp;
   450   451   452   453   454   455   456   457   458   459   460