-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStock.java
90 lines (81 loc) · 3.92 KB
/
Stock.java
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
import java.util.Scanner;
class Stock {
int milliLiterWater = 6000;
int milliLiterMilk = 1500;
int gramsOfCoffeeBeans = 450;
int amountCoffeeCups = 30;
int amountCoffeeCupsWanted = 0;
int totalMoneyinCoffeeMachine = 0;
int totalCupsWater = milliLiterWater / 200;
int totalCupsMilk = milliLiterMilk / 50;
int totalCupsCoffeeBeans = gramsOfCoffeeBeans / 15;
int totalCupsCoffee = 0;
Coffee coffeeChoosen = null;
private Scanner scanner = new Scanner(System.in);
void fillCoffeeMachine() {
System.out.println("Write how many ml of water do you want to add: ");
int mlWatertoAddCoffeeMachine = Integer.parseInt(scanner.nextLine());
milliLiterWater += mlWatertoAddCoffeeMachine;
System.out.println("Write how many ml of milk do you want to add: ");
int mlMilktoAddCoffeeMachine = Integer.parseInt(scanner.nextLine());
milliLiterMilk += mlMilktoAddCoffeeMachine;
System.out.println("Write how many grams of coffee beans do you want to add: ");
int gCoffeeBeanstoAddCoffeeMachine = Integer.parseInt(scanner.nextLine());
gramsOfCoffeeBeans += gCoffeeBeanstoAddCoffeeMachine;
System.out.println("Write how many disposable cups of coffee do you want to add: ");
int disposableCupstoAddCoffeeMachine = Integer.parseInt(scanner.nextLine());
amountCoffeeCups += disposableCupstoAddCoffeeMachine;
}
void takeMoneyCoffeeMachine() {
System.out.println("I gave you €" + totalMoneyinCoffeeMachine);
totalMoneyinCoffeeMachine = 0;
}
void removeStockCoffeeMachine() {
milliLiterWater += -coffeeChoosen.milliLiterWaterCoffee * amountCoffeeCupsWanted;
milliLiterMilk += -coffeeChoosen.milliLiterMilkCoffee * amountCoffeeCupsWanted;
gramsOfCoffeeBeans += -coffeeChoosen.gramsOfCoffeeBeansCoffee * amountCoffeeCupsWanted;
totalMoneyinCoffeeMachine += coffeeChoosen.price * amountCoffeeCupsWanted;
}
void CalculateRemainingCoffeeCups(String sortOfCoffee) {
switch (sortOfCoffee) {
case "0":
totalCupsWater = milliLiterWater / 200;
totalCupsMilk = milliLiterMilk / 50;
totalCupsCoffeeBeans = gramsOfCoffeeBeans / 15;
break;
case "1":
totalCupsWater = milliLiterWater / 250;
totalCupsMilk = milliLiterMilk / 1;
totalCupsCoffeeBeans = gramsOfCoffeeBeans / 16;
break;
case "2":
totalCupsWater = milliLiterWater / 350;
totalCupsMilk = milliLiterMilk / 75;
totalCupsCoffeeBeans = gramsOfCoffeeBeans / 20;
break;
case "3":
totalCupsWater = milliLiterWater / 200;
totalCupsMilk = milliLiterMilk / 100;
totalCupsCoffeeBeans = gramsOfCoffeeBeans / 12;
break;
}
if (totalCupsWater == totalCupsMilk && totalCupsCoffeeBeans == totalCupsWater) {
totalCupsCoffee = totalCupsWater;
} else if (totalCupsMilk >= totalCupsWater && totalCupsCoffeeBeans >= totalCupsWater) {
totalCupsCoffee = totalCupsWater;
} else if (totalCupsWater >= totalCupsMilk && totalCupsCoffeeBeans >= totalCupsMilk) {
totalCupsCoffee = totalCupsMilk;
} else if (totalCupsMilk >= totalCupsCoffeeBeans && totalCupsWater >= totalCupsCoffeeBeans) {
totalCupsCoffee = totalCupsCoffeeBeans;
} else {
System.err.println("Ah shit here we go again\n" +
totalCupsWater + "\n" +
totalCupsMilk + "\n" +
totalCupsCoffeeBeans + "\n" +
totalCupsCoffee);
}
if (totalCupsCoffee > amountCoffeeCups) {
totalCupsCoffee = amountCoffeeCups;
}
}
}