-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathManager_IM.java
More file actions
91 lines (82 loc) · 2.53 KB
/
Manager_IM.java
File metadata and controls
91 lines (82 loc) · 2.53 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
/**
* This class is an abstraction for the manager.
* The manager has their balance as an instance.
*
* @IMukhametzhanova
* @1.8
* 11/8/18
*/
public class Manager_IM
{
private double money;
/**
* Constructor with zero balance
*/
public Manager_IM ()
{
this.money = 0;
}
/**
* Constructor with entered balance
*/
public Manager_IM (int money)
{
this.money = money;
}
/**
* Get the current balance
*/
public double getMoney()
{
return money;
}
/**
* Add to the balance
*/
public void addMoney(double amt)
{
money += amt;
}
/**
* Will allow for restock of snacks
*/
public void restockS(Inventory_IM inv, int snackNum)
{
double cost = inv.getCostBulkS().get(snackNum);//get the cost of bulk
if (cost > money){//not enough balance
System.out.println("Your balance is insufficient, peasant");
}else{
double numBoughtDouble = cost / inv.getSnacks().get(snackNum).getCost();//divide the cost of bulk by cost of one to get the maximum number of units that can be bought
int numBought = (int)Math.floor(numBoughtDouble);
inv.addToStockS(snackNum, numBought);//add the new units
money -= cost;
System.out.println("Bought: " + inv.getSnacks().get(snackNum).getName());
System.out.println("Your current balance is " + money);
}
}
/**
* Will allow for restock of drinks
*/
public void restockD(Inventory_IM inv, int drinkNum)
{
double cost = inv.getCostBulkD().get(drinkNum);
if (cost > money){
System.out.println("Your balance is insufficient, peasant");
}else{
double numBoughtDouble = cost / inv.getDrinks().get(drinkNum).getCost();//divide the cost of bulk by cost of one to get the maximum number of units that can be bought
int numBought = (int)Math.floor(numBoughtDouble);
inv.addToStockD(drinkNum, numBought);//add the new units
money -= cost;
System.out.println("Bought: " + inv.getDrinks().get(drinkNum).getName());
System.out.println("Your current balance is " + money);
}
}
/**
* Converts the object's info into string
*/
public String toString()
{
String output = "Current balance (manager): $" + money;
return output;
}
}