-
Notifications
You must be signed in to change notification settings - Fork 0
/
dm11_建造者模式_问题抛出.cpp
107 lines (92 loc) · 1.4 KB
/
dm11_建造者模式_问题抛出.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <iostream>
using namespace std;
#include "string"
class House
{
public:
void setDoor(string door)
{
this->m_door = door;
}
void setWall(string wall)
{
this->m_wall = wall;
}
void setWindow(string window)
{
this->m_window = window;
}
//--
string getDoor( )
{
cout << m_door << endl;
return this->m_door ;
}
string getWall()
{
cout << m_wall << endl;
return this->m_wall;
}
string getWindow()
{
cout << m_window << endl;
return m_window;
}
private:
string m_door;
string m_wall;
string m_window;
};
class Build
{
public:
Build()
{
m_house = new House;
}
void makeBuild()
{
buildDoor(m_house);
buildWall(m_house);
buildWindow(m_house);
}
void buildDoor(House *h)
{
h->setDoor("壇");
}
void buildWall(House *h)
{
h->setWall("能");
}
void buildWindow(House *h)
{
h->setWindow("完");
}
House *getHouse()
{
return m_house;
}
private:
House *m_house;
};
void main()
{
/* 人薩岷俊夛型徨
House *house = new House;
house->setDoor("壇");
house->setWall("能中");
house->setWindow("完笥");
delete house;
*/
//萩垢殻錦 秀夛型徨
House *house = NULL;
Build * build = new Build;
build->makeBuild();
house = build->getHouse();
house->getDoor();
house->getWall();
house->getWindow();
cout<<"hello..."<<endl;
system("pause");
return ;
}