-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcar_factory.js
126 lines (119 loc) · 2.41 KB
/
car_factory.js
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**
In this project, we need to create a series of car objects defined in code.
We don't want to create 1 car, we want to create a system for creating cars given
a set of customer specifications. Create a small program that outputs a final
car object for each order with methods that correspond to the customer demands, and that give us the
full name of the customer, the customer's address, and the final purchase price
We should be able to access the total price like:
car.finalPrice() #returns 24,000
and access the horn like
car.horn() #returns "Normal Honk"
car.ownerName() #returns "Firstname Lastname";
*/
var orders = [
{
firstName: 'Bill',
lastName: 'Smith',
type: 'sedan',
doors: 4,
basePrice: 20000,
paint: 'blue',
options: [
{
type: 'honk',
style: 'enhanced',
price: 4000
},
{
type: 'interior',
style: 'leather',
price: 5000
},
{
type: 'engine',
style: 'regular',
price: 0
}
]
},
{
firstName: 'Susan',
lastName: 'Anderson',
type: 'truck',
doors: 2,
basePrice: 25000,
paint: 'green',
options: [
{
type: 'honk',
style: 'fancy',
price: 8000
},
{
type: 'interior',
style: 'endangeredZebraLeather',
price: 8000
},
{
type: 'engine',
style: 'turbocharge',
price: 10000
}
]
},
{
firstName: 'Rachel',
lastName: 'Hoekstra',
type: 'convertable',
doors: 2,
basePrice: 15000,
paint: 'red',
options: [
{
type: 'topColor',
style: 'white',
price: 1000
},
{
type: 'honk',
style: 'regular',
price: 0
},
{
type: 'interior',
style: 'cloth',
price: 0
},
{
type: 'engine',
style: 'electric',
price: 2000
}
]
},
{
firstName: 'Elon',
lastName: 'Musk',
type: 'sedan',
doors: 4,
basePrice: 20000,
paint: 'spaceGray',
options: [
{
type: 'flight',
style: 'supersonic',
price: 500000
},
{
type: 'interior',
style: 'cloth',
price: 0
},
{
type: 'engine',
style: 'jet',
price: 20000
}
]
}
];