DesignPattern/05.PrototypePattern/2.Code/main.cpp

52 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "PrototypePattern.h"
int main()
{
#if 0
ConcreteWork *singleWork = new ConcreteWork("Single",1001,"Single_Model");
printf("\nSingle的作业\n");
singleWork->printWorkInfo();
printf("\njungle直接抄作业……\n");
ConcreteWork *jungleWork = singleWork;
printf("\nJungle的作业\n");
jungleWork->printWorkInfo();
//抄完改名字和学号,否则会被老师查出来
printf("\njungle抄完改名字和学号否则会被老师查出来……\n");
jungleWork->setName("jungle");
jungleWork->setIdNum(1002);
WorkModel *jungleModel = new WorkModel();
jungleModel->setWorkModelName("Jungle_Model");
jungleWork->setModel(jungleModel);
//检查下是否改对了
printf("\nSingle的作业\n");
singleWork->printWorkInfo();
printf("\nJungle的作业\n");
jungleWork->printWorkInfo();
#endif
ConcreteWork *singleWork = new ConcreteWork("Single", 1001, "Single_Model");
printf("\nSingle的作业\n");
ConcreteWork *jungleWork = singleWork->clone();
printf("\nJungle的作业\n");
//抄完改名字和学号,否则会被老师查出来
printf("\njungle抄完改名字和学号否则会被老师查出来……\n");
jungleWork->setName("jungle");
jungleWork->setIdNum(1002);
WorkModel *jungleModel = new WorkModel();
jungleModel->setWorkModelName("Jungle_Model");
jungleWork->setModel(jungleModel);
//检查下是否改对了
printf("\nSingle的作业\n");
singleWork->printWorkInfo();
printf("\nJungle的作业\n");
jungleWork->printWorkInfo();
system("pause");
return 0;
}