2019-11-10 14:59:08 +00:00
|
|
|
|
#ifndef __VISITOR_H__
|
|
|
|
|
#define __VISITOR_H__
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
// ǰ<><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
class Element;
|
|
|
|
|
class Apple;
|
|
|
|
|
class Book;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
class Visitor
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Visitor(){};
|
2021-04-04 13:09:08 +00:00
|
|
|
|
virtual ~Visitor(){}
|
2019-11-10 14:59:08 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7><EFBFBD>
|
|
|
|
|
virtual void visit(Apple*) = 0;
|
|
|
|
|
virtual void visit(Book*) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD><DFA3>˿<EFBFBD>
|
|
|
|
|
class Customer :public Visitor
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Customer();
|
|
|
|
|
Customer(string iName);
|
|
|
|
|
void setNum(Apple*, int);
|
|
|
|
|
void setNum(Book*, int);
|
|
|
|
|
void visit(Apple* apple);
|
|
|
|
|
void visit(Book* book);
|
|
|
|
|
private:
|
|
|
|
|
string name;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD><DFA3><EFBFBD><EFBFBD><EFBFBD>Ա
|
|
|
|
|
class Cashier :public Visitor
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Cashier();
|
|
|
|
|
void visit(Apple* apple);
|
|
|
|
|
void visit(Book* book);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|