Protected:
Int bookID;
String bookname;
Double price.
Double discount.
Int number;
Double the total;
Public:
Cart (int b_id, string b_na, double pr, int n, double d, int t)
{
BookID=b_id;
Bookname=b_na;
Price=pr;
Number=n;
Double=d;
Total=t;
}
Void SelectFunction ()
{
Int number=0;
Do {
The menu ();
Cout<& lt;" Please enter the number to choose: \ n ";
cin> Number;
The switch (number) {
Case 1:
The Add ();
break;
Case 2:
Remove ();
break;
Case 3:
MendShoppingList ();
break;
Case 4:
The display ();
break;
Default:
break;
}
} while (number!=5);
}
Void the Add (book * [b])
{
Int bookID=0, number=0;
Cout<& lt;" Please enter the number: \ n ";
cin> BookID;
Cout<& lt;" Please enter the purchase quantity: \ n ";
cin> Number;
Int flag=0;
for(int i=0; i<3; I++) {
If (b [I] bookID==bookID) {
B [I] number +=number;
Flag=1;
Cout<& lt;" Add books success! \ n ";
break;
}
}
If (flag==0) {
Cout<& lt;" Have the books \ n ";
}
}
Void the Remove (book * [b])
{
Int bookID=0, number=0;
Cout<& lt;" Please enter the number: \ n ";
cin> BookID;
Cout<& lt;" Please enter the purchase quantity: \ n ";
cin> Number;
Int flag=0;
for(int i=0; i<3; I++) {
If (b [I] bookID==bookID & amp; & B [I] number> 0)
[I] {b number=0;
Flag=1;
Cout<& lt;" The book was removed successfully! \ n ";
break;
}
}
If (flag==0)
{cout<& lt;" Have the books \ n ";
}
}
Void MendShoppingList (book * [b])
{
Int bookID=0, number=0;
Cout<& lt;" Please enter the number: \ n ";
cin> BookID;
Cout<& lt;" Please enter the purchase quantity: \ n ";
cin> Number;
Int flag=0;
for(int i=0; i<3; I++) {
If (b [I] bookID==bookID & amp; & B [I] number> 0)
[I] {b number -=number;
Flag=1;
Cout<& lt;" Modify the success! \ n ";
break;
}
}
If (flag==0)
{cout<& lt;" Books add to cart \ n ";
}
}
Void total (book * [b])
{
Cout<& lt;" * * * * * * * * the current shopping cart books * * * * * * * * \ n ";
Double sum=0;
for(int i=0; i<3; I++) {
If (b [I] number> 0 {
CoutThe sum a + b=[I]. Total;
}
}
Cout<& lt;" The current total: \ t "& lt;
Void the display ()
{
Cout<& lt;" * * * * * * * * * * * * * * * * * * * * \ n ";
Cout<& lt;" 1. Add books \ n ";
Cout<& lt;" 2. Modify the books \ n ";
Cout<& lt;" 3. Remove the book list \ n ";
Cout<& lt;" 4. According to the total \ n ";
Cout<& lt;" * * * * * * * * * * * * * * * * * * * * \ n ";
}
};