-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDay23.java
More file actions
142 lines (110 loc) · 4.54 KB
/
Day23.java
File metadata and controls
142 lines (110 loc) · 4.54 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
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
// ---------------------------------------------------
// Author : Benjamin Kataliko Viranga
// Community : Stunt Business
// Community website : www.stuntbusiness.com
//
// 30 Days - Q&A Java basic
// Day 23 : Challenge XI - Your 'Mini Store'.
// Day 23 | IG : https://www.instagram.com/benjivrik/
// ----------------------------------------------------
// what would be the output of this program ?
/**
* Create your Store
*
* Create three employees and set the isWorking to True for two of them.
*
* Assign these employees to the store
*
* Get the list of employees from the store and print them on your terminal (showing which employee is working and not working)
*
* Create four Items with the following prices 200,1200,15 and 12.75
*
* Create two customers with the following budget 1500 and 45
*
* The first customer ( budget 1500 CAD ) should be able to buy 3 of the items without any problem
*
* The second customer ( budget 45 CAD ) should try to buy the item at 1200 CAD and the one at 12.75 CAD
*
* You should expect him to be denied to buy the items based on the function buy() implemented in the Customer class
*
* Now, remove the item at 1200 CAD
*
* Let the second customer buys the items
*
* Display the store information
*
*/
public class Day23
{
public static void main(String[] args)
{
Store store = new Store("Stunt-Business");
// initialize three employees and add them to the store
// Two of them should have their status changed to 'working' when you assign them to the store
// first employee
Employee employee = new Employee("Jivrik", 15);
employee.status(); // isWorking to True
store.addEmployee(employee);
// second employee
employee = new Employee("Kavrik", 18.7);
employee.status(); // isWorking to True
store.addEmployee(employee);
//third employee
employee = new Employee("bevrik", 75);
store.addEmployee(employee);
// get the list of employees and display them to your terminal showing their status
System.out.println("\nWhich employee is currently working? (True for 'working' | False for 'not working')");
for(Employee emp : store.getEmployees())
{
System.out.printf("\n> %s : %s\n", emp.getName(), emp.getWorkStatus());
}
// add items in your store
Item computer = new Item("laptop", "computer", 200);
Item tv = new Item("TV", "computer", 1200);
Item orange = new Item("orange", "fruit", 15);
Item banana = new Item("banana", "fruit", 12.75);
// adding five laptops to the store
store.addItem(computer, 5);
// add ten Tvs in the store
store.addItem(tv,10);
// adding ten oranges to the store
store.addItem(orange, 10);
// add twenty bananas in the store
store.addItem(banana,20);
//display details about the store
System.out.println(store);
// Create two customers
Customer customerOne = new Customer("Tim", 1500);
Customer customerTwo = new Customer("Tristan", 45);
// set store
customerOne.setStore(store);
customerTwo.setStore(store);
System.out.println("\n>>>> Adding items in the chart of the first customer <<<<\n");
// add item to the cart of the first customer
customerOne.addToCart("laptop");
customerOne.addToCart("orange");
customerOne.addToCart("TV");
// display info about the customer
System.out.println(customerOne);
System.out.println("\n>>>> First customer buying items. <<<<\n");
// buy items for your first customer
customerOne.buy();
System.out.println("\n>>>> Adding items in the chart of the second customer <<<<\n");
// add item to the cart of the second customer
customerTwo.addToCart("banana");
customerTwo.addToCart("TV");
// display info about the customer
System.out.println(customerTwo);
System.out.println("\n>>>> Second customer buying items. <<<<\n");
// buy items for your second customer
customerTwo.buy();
System.out.println("\n>>>> Second customer removing items. <<<<\n");
customerTwo.removeFromCart("TV");
// display info about the customer
System.out.println(customerTwo);
System.out.println("\n>>>> Second customer buying items. <<<<\n");
customerTwo.buy();
//display details about the store
System.out.println(store);
}
}