2019-11-10 14:59:08 +00:00
|
|
|
#include "Visitor.h"
|
|
|
|
#include "Element.h"
|
|
|
|
|
|
|
|
/***** Customer *******/
|
|
|
|
Customer::Customer(){
|
|
|
|
this->name = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
Customer::Customer(string iName){
|
|
|
|
this->name = iName;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Customer::setNum(Apple* apple, int iNum){
|
|
|
|
apple->setNum(iNum);
|
|
|
|
}
|
|
|
|
void Customer::setNum(Book* book, int iNum){
|
|
|
|
book->setNum(iNum);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Customer::visit(Apple* apple){
|
|
|
|
int price = apple->getPrice();
|
2021-10-28 15:15:51 +00:00
|
|
|
printf(" %s \t单价: \t%d 元/kg\n", apple->getName().c_str(), apple->getPrice());
|
2019-11-10 14:59:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Customer::visit(Book* book){
|
|
|
|
int price = book->getPrice();
|
|
|
|
string name = book->getName();
|
2021-10-28 15:15:51 +00:00
|
|
|
printf(" 《%s》\t单价: \t%d 元/本\n", book->getName().c_str(), book->getPrice());
|
2019-11-10 14:59:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***** Cashier *******/
|
|
|
|
Cashier::Cashier(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cashier::visit(Apple* apple){
|
|
|
|
string name = apple->getName();
|
|
|
|
int price = apple->getPrice();
|
|
|
|
int num = apple->getNum();
|
|
|
|
int total = price*num;
|
2021-10-28 15:15:51 +00:00
|
|
|
printf(" %s 总价: %d 元\n", name.c_str(), total);
|
2019-11-10 14:59:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Cashier::visit(Book* book){
|
|
|
|
int price = book->getPrice();
|
|
|
|
string name = book->getName();
|
|
|
|
int num = book->getNum();
|
|
|
|
int total = price*num;
|
2021-10-28 15:15:51 +00:00
|
|
|
printf(" 《%s》 总价: %d 元\n", name.c_str(), total);
|
2019-11-10 14:59:08 +00:00
|
|
|
}
|