forked from yusufyilmazf/takim4_proje
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFactoryManagementSystem\.go
424 lines (368 loc) · 9.6 KB
/
FactoryManagementSystem\.go
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
package main
import (
"fmt"
"strings"
"time"
)
const sharp = "#"
type matter struct { // Struct olarak mobilya hammadesi genel tanımlandı
idNumber int
name string
stock float32
quality float32
unitPrice float32
}
type furniture struct { // Struct olarak mobilya genel tanımlandı
idNumber int
typePortable bool
name string
length float32
width float32
heigth float32
color matter // boyanin ozellikleri
material matter // kullanilan malzemenin ozellikleri
orderNumber int
}
func progressBar() {
for i := 0; i < 101; i++ {
fmt.Printf("\r[%-100s] %d%%", strings.Repeat(sharp, i), i)
time.Sleep(10 * time.Millisecond)
}
fmt.Println("")
}
func main() {
// sonsuz dongu
furnitureS := []furniture{ // kullanici default olarak gelen mobilyalari ozellestirmemis
// hazir setler kisminda bu yapiyi kullanalim ama bu asamada kullanici mobilya ozelliklerini kendi girdigi halini eklememiz gerekiyor
{
name: "Seat",
idNumber: 0,
width: 90,
heigth: 50,
length: 110,
typePortable: false,
},
{
name: "Chair",
idNumber: 1,
width: 35,
heigth: 96,
length: 41,
typePortable: true,
},
{
name: "Table",
idNumber: 2,
width: 80,
heigth: 75,
length: 140,
typePortable: true,
},
{
name: "Wardrobe",
idNumber: 3,
width: 50,
heigth: 190,
length: 210,
typePortable: false,
},
{
name: "Coffee Table",
idNumber: 4,
width: 50,
heigth: 42,
length: 50,
typePortable: true,
},
{
name: "TV Unit",
idNumber: 5,
width: 35,
heigth: 50,
length: 180,
typePortable: false,
},
{
name: "Bed",
idNumber: 6,
width: 80,
heigth: 50,
length: 200,
typePortable: false,
},
}
paints := []matter{
matter{
idNumber: 1,
name: "Best Red Paint",
stock: 500,
quality: 9,
unitPrice: 35,
},
matter{
idNumber: 2,
name: "Best Blue Paint",
stock: 500,
quality: 9,
unitPrice: 32,
},
matter{
idNumber: 3,
name: "Best Green Paint",
stock: 500,
quality: 9,
unitPrice: 39,
},
matter{
idNumber: 4,
name: "Midle Red Paint",
stock: 500,
quality: 6,
unitPrice: 24,
},
matter{
idNumber: 5,
name: "Midle Blue Paint",
stock: 500,
quality: 6,
unitPrice: 22,
},
matter{
idNumber: 6,
name: "Best Green Paint",
stock: 500,
quality: 6,
unitPrice: 27,
},
}
materials := []matter{
matter{
idNumber: 1,
name: "Oak Wood",
stock: 500,
quality: 9,
unitPrice: 35,
},
matter{
idNumber: 2,
name: "Walnut Wood",
stock: 500,
quality: 9,
unitPrice: 32,
},
matter{
idNumber: 3,
name: "Pine Wood",
stock: 500,
quality: 9,
unitPrice: 39,
},
matter{
idNumber: 4,
name: "Willow Wood",
stock: 500,
quality: 6,
unitPrice: 24,
},
matter{
idNumber: 5,
name: "Cherry Wood",
stock: 500,
quality: 6,
unitPrice: 22,
},
matter{
idNumber: 6,
name: "Poplar Wood",
stock: 500,
quality: 6,
unitPrice: 27,
},
}
for {
for {
var chosenFurniture furniture
var chosenPaint matter
var chosenMaterial matter
var chosenFurnitureID int
var chosenMaterialID int
var chosenPaintID int
furnitureSliceShow(furnitureS)
fmt.Println(" ")
fmt.Println("Choose one of this furnitures to customize")
fmt.Println(" ")
for {
fmt.Scan(&chosenFurnitureID)
if (chosenFurnitureID > len(furnitureS)) || (chosenFurnitureID <= 0) {
fmt.Println("Please enter a vailed valu for ID number:")
} else {
break
}
} // mobilya ID secimi icin gereken hatasiz for sonu
// mobilya secimi ve eslemesi yapildi
var membersNumber int = 0
for furnitureS[membersNumber].idNumber != chosenFurnitureID {
if furnitureS[membersNumber].idNumber == chosenFurnitureID {
furnitureS[membersNumber] = chosenFurniture
}
membersNumber++
}
chosenFurniture = furnitureS[membersNumber]
chosenFurniture.showFurniture()
// maddesini ve boyasini kullanici girecek
fmt.Println(" ")
fmt.Println(" ")
matterSliceShow(paints)
fmt.Println("Enter the paint ID number of the paint you want ")
var mambersofPaintsNumbers int
// dogru girdi alinacak ve ID paint icin alinmis olacak
for {
fmt.Scan(&chosenPaintID)
if (chosenPaintID > len(paints)) || (chosenPaintID <= 0) {
fmt.Println("Please enter a true value for ID number:")
} else {
break
}
}
// alinan id slice ile karsilastirilip boya tespit edilecek
for paints[mambersofPaintsNumbers].idNumber != chosenPaintID {
if paints[mambersofPaintsNumbers].idNumber == chosenPaintID {
}
mambersofPaintsNumbers++
}
// alinan id secilen boyayla esitlenecek
chosenPaint = paints[mambersofPaintsNumbers]
chosenFurniture.color = chosenPaint
fmt.Println(" ")
fmt.Println(" ")
// materyal secimi yaptirilacak
fmt.Println("***** MATERIALS*****")
fmt.Println(" ")
var memberNumberofMaterials int
fmt.Println(" ")
matterSliceShow(materials)
fmt.Println(" ")
fmt.Println("Chose one of the materials you want :")
for {
fmt.Scan(&chosenMaterialID)
if (chosenMaterialID > len(materials)) || (chosenMaterialID <= 0) {
fmt.Println("Please enter a true valu for ID number:")
} else {
break
}
}
for materials[memberNumberofMaterials].idNumber != chosenMaterialID {
if materials[memberNumberofMaterials].idNumber == chosenMaterialID {
}
memberNumberofMaterials++
}
chosenMaterial = materials[memberNumberofMaterials]
chosenFurniture.material = chosenMaterial
fmt.Println(" ")
fmt.Println(" ")
fmt.Println("Furniture you have costumized :")
chosenFurniture.showFurniture()
fmt.Println("The price of the ", chosenFurniture.name, "is :", priceCalculator(chosenFurniture))
var neededMaterial float32
neededMaterial = chosenFurniture.heigth * chosenFurniture.length * chosenFurniture.width / 1000
if (chosenFurniture.color.stock < neededMaterial) || (chosenFurniture.material.stock < neededMaterial) {
fmt.Println("There is not enough material for production, there is gonig to be a order procces. ")
progressBar()
fmt.Println("Order completed your order will be ready in 24 hours.")
chosenFurniture.color.stock = chosenFurniture.color.stock + neededMaterial
chosenFurniture.material.stock = chosenFurniture.material.stock + neededMaterial
}
chosenFurniture.color.stock = chosenFurniture.color.stock - neededMaterial
chosenFurniture.material.stock = chosenFurniture.material.stock - neededMaterial
fmt.Println(chosenFurniture.color.stock)
progressBar()
} // Furniture sectiyse burasai calisacak
} // iner for loop
}
// ctrl c harici calismaya devam etmesi icin
func (furn furniture) showFurniture() {
fmt.Println("Furniture name : ", furn.name)
if furn.typePortable == true {
fmt.Println(furn.name, "is portable")
fmt.Println(" ")
} else {
fmt.Println(furn.name, "is not portable")
fmt.Println(" ")
}
fmt.Println("ID number of", furn.name, "is : ", furn.idNumber)
fmt.Println(" ")
if furn.length != 0 {
fmt.Println("Length of", furn.name, "is : ", furn.length)
fmt.Println(" ")
}
if furn.width != 0 {
fmt.Println("Width of", furn.name, "is : ", furn.width)
fmt.Println(" ")
}
if furn.heigth != 0 {
fmt.Println("Higth of", furn.name, "is : ", furn.width)
fmt.Println(" ")
}
if furn.color.idNumber > 0 {
fmt.Print("The color you chose is : ")
furn.color.showMaterial()
fmt.Println(" ")
}
if furn.material.idNumber > 0 {
fmt.Print("Material you chose is")
furn.material.showMaterial()
}
}
func (raw matter) showMaterial() {
fmt.Println(raw.name)
fmt.Println("ID number of", raw.name, "is : ", raw.idNumber)
fmt.Println("Stock amount : ", raw.stock)
fmt.Println("Quality value out of 10 is : ", raw.quality)
fmt.Println("Unit Price : ", raw.unitPrice, "TL")
}
func furnitureSliceShow(furnitureSet []furniture) { // slice elemanlarını sergilememizi sağlar
fmt.Println("***** FURNITURES *****")
fmt.Println(" ")
var i int = len(furnitureSet) - 1
for 0 <= i {
furnitureSet[i].showFurniture()
fmt.Println(" ")
i -= 1
}
}
func matterSliceShow(matters []matter) {
fmt.Println("***** Matter *****")
fmt.Println(" ")
var n int = len(matters) - 1
for 0 <= n {
matters[n].showMaterial()
fmt.Println(" ")
n -= 1
}
}
func orderProgres(furn furniture) {
var neededMaterial float32
neededMaterial = furn.heigth * furn.length * furn.width
if (furn.material.stock < neededMaterial) || (furn.color.stock < neededMaterial) {
fmt.Println("There is not enough material for production ")
fmt.Println("Material order is preparing")
furn.color.stock = neededMaterial
furn.material.stock = neededMaterial
progressBar()
fmt.Println("Stock has been updated. ")
}
if (furn.material.stock >= neededMaterial) || (furn.color.stock >= neededMaterial) {
progressBar()
var newStockMaterial float32
var newStockColor float32
newStockColor = furn.color.stock - neededMaterial
newStockMaterial = furn.material.stock - neededMaterial
furn.color.stock = newStockColor
furn.material.stock = newStockMaterial
}
}
func priceCalculator(furn furniture) float32 {
price := (furn.length * furn.heigth * furn.width) * (furn.color.unitPrice) * (furn.material.unitPrice) / 100
return price
}
// how to write a struct includes a slice