2019-11-10 14:59:08 +00:00
|
|
|
|
#include "Element.h"
|
|
|
|
|
#include "Visitor.h"
|
|
|
|
|
#include "ShoppingCart.h"
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
Apple *apple1 = new Apple("<EFBFBD>츻ʿƻ<EFBFBD><EFBFBD>", 7);
|
|
|
|
|
Apple *apple2 = new Apple("<EFBFBD><EFBFBD>ţƻ<EFBFBD><EFBFBD>", 5);
|
|
|
|
|
Book *book1 = new Book("<EFBFBD><EFBFBD>¥<EFBFBD><EFBFBD>", 129);
|
|
|
|
|
Book *book2 = new Book("<EFBFBD>ս<EFBFBD><EFBFBD><EFBFBD>", 49);
|
|
|
|
|
|
|
|
|
|
Cashier* cashier = new Cashier();
|
|
|
|
|
Customer* jungle = new Customer("Jungle");
|
|
|
|
|
jungle->setNum(apple1, 2);
|
|
|
|
|
jungle->setNum(apple2, 4);
|
|
|
|
|
jungle->setNum(book1, 1);
|
|
|
|
|
jungle->setNum(book2, 3);
|
|
|
|
|
|
|
|
|
|
ShoppingCart* shoppingCart = new ShoppingCart();
|
|
|
|
|
shoppingCart->addElement(apple1);
|
|
|
|
|
shoppingCart->addElement(apple2);
|
|
|
|
|
shoppingCart->addElement(book1);
|
|
|
|
|
shoppingCart->addElement(book2);
|
|
|
|
|
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
shoppingCart->accept(jungle);
|
|
|
|
|
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
shoppingCart->accept(cashier);
|
|
|
|
|
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
system("pause");
|
2020-11-29 02:02:40 +00:00
|
|
|
|
|
|
|
|
|
delete apple1;
|
|
|
|
|
delete apple2;
|
|
|
|
|
delete book1;
|
|
|
|
|
delete book2;
|
|
|
|
|
delete cashier;
|
|
|
|
|
delete jungle;
|
|
|
|
|
delete shoppingCart;
|
|
|
|
|
|
2019-11-10 14:59:08 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|