DesignPattern/24.VisitorPattern/2.Code/Element.cpp

34 lines
509 B
C++
Raw Normal View History

2019-11-10 14:59:08 +00:00
#include "Element.h"
/***** Apple *******/
Apple::Apple(){
setPrice(0);
setNum(0);
setName("");
}
Apple::Apple(string name, int price){
setPrice(price);
setNum(0);
setName(name);
}
void Apple::accept(Visitor* visitor){
visitor->visit(this);
}
/***** Book *******/
Book::Book(){
setPrice(0);
setNum(0);
setName("");
}
Book::Book(string iName, int iPrice){
setPrice(iPrice);
setNum(0);
setName(iName);
}
void Book::accept(Visitor* visitor){
visitor->visit(this);
}