-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToyFactory.cxx
More file actions
52 lines (45 loc) · 1.34 KB
/
ToyFactory.cxx
File metadata and controls
52 lines (45 loc) · 1.34 KB
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
//-----------------------------------------------------------------------------
// File: ToyFactory.cxx
// Author: Enhope
// Date: 31-05-2019
//-----------------------------------------------------------------------------
#include <factory_method_pattern/ToyFactory.hxx>
#include "Bike.hxx"
#include "Car.hxx"
#include "Plane.hxx"
#include <plog/Log.h>
//-----------------------------------------------------------------------------
ToyFactory::ToyFactory()
{
PLOGD;
}
//-----------------------------------------------------------------------------
ToyFactory::~ToyFactory()
{
PLOGD;
}
//-----------------------------------------------------------------------------
Toy::ToyPtr ToyFactory::createToy(Factory::ToyType type)
{
Toy::ToyPtr return_toy;
switch(type)
{
case Factory::BIKE:
PLOGI << "Making the bike toy";
return_toy = Toy::ToyPtr(new Bike("Bike Toy", 10));
break;
case Factory::CAR:
PLOGI << "Making the car toy";
return_toy = Toy::ToyPtr(new Car("Car Toy", 35));
break;
case Factory::PLANE:
PLOGI << "Making the plane toy";
return_toy = Toy::ToyPtr(new Plane("Plane Toy", 50));
break;
}
return_toy->prepareParts();
return_toy->combineParts();
return_toy->assembleParts();
return_toy->applyLabel();
return return_toy;
}