forked from jcrouser/CSC120-A8
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCafe.java
More file actions
114 lines (92 loc) · 4.76 KB
/
Cafe.java
File metadata and controls
114 lines (92 loc) · 4.76 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
/* This is a stub for the Cafe class */
public class Cafe extends Building {
private int nCoffeeOunces; // The number of ounces of coffee remaining in inventory
private int nSugarPackets; // The number of sugar packets remaining in inventory
private int nCreams; // The number of "splashes" of cream remaining in inventory
private int nCups; // The number of cups remaining in inventory
/**
* @param name Cafe name
* @param address Cafe address
* @param nFloors Number of floors in cafe
* @param nCoffeeOunces Ounces of coffee available
* @param nSugarPackets Number of sugar packets available
* @param nCreams Number of cream available
* @param nCups Number of cups available
*/
public Cafe(String name, String address, int nFloors, int nCoffeeOunces, int nSugarPackets, int nCreams, int nCups) {
super(name, address, nFloors);
this.nCoffeeOunces = nCoffeeOunces;
this.nSugarPackets = nSugarPackets;
this.nCreams = nCreams;
this.nCups = nCups;
System.out.println("You have built a cafe: ☕");
}
/**
* Restocks the ingredients in stock
* @param nCoffeeOunces Ounces of coffee
* @param nSugarPackets Number of sugar packets
* @param nCreams Amount of cream
* @param nCups Number of cups
*/
private void restock(int nCoffeeOunces, int nSugarPackets, int nCreams, int nCups){
this.nCoffeeOunces += 100;
this.nSugarPackets += 100;
this.nCreams += 100;
this.nCups += 100;
}
// method that will lower values within the parameter meaning a cup of cofee was purchased
/**
*
* @param size size requested for drink
* @param nSugarPackets number of sugar packets requested
* @param nCreams number of creams requested
*/
public void sellCoffee(int size, int nSugarPackets, int nCreams){
if(size > this.nCoffeeOunces||nSugarPackets > this.nSugarPackets|| nCreams > this.nCreams|| nCups > this.nCups){
restock(this.nCoffeeOunces, this.nSugarPackets, this.nCreams, this.nCups);
System.out.println("Items at Cafe have been restocked: Coffee = " + this.nCoffeeOunces + " oz, Sugar packets = " + this.nSugarPackets + " packets, Creams = " + this.nCreams + " splashes of cream, Cups = " + this.nCups + " cups.");
}
// values of Parameter (in this case all ints) decrease
this.nCoffeeOunces -= size;
this.nSugarPackets -= nSugarPackets;
this.nCreams -= nCreams;
this.nCups -= 1;
System.out.println("Here is your order of" + size + " oz coffee with " + nSugarPackets + " sugar packets and " + nCreams + " pumps of cream. Have a great day!");
}
// sellCoffee overloaded
public void sellCoffee(int size, int nSugarPackets, int nCreams, int cupsRequested){
if(size > this.nCoffeeOunces||nSugarPackets > this.nSugarPackets|| nCreams > this.nCreams|| nCups > this.nCups){
restock(this.nCoffeeOunces, this.nSugarPackets, this.nCreams, this.nCups);
System.out.println("Items at Cafe have been restocked: Coffee = " + this.nCoffeeOunces + " oz, Sugar packets = " + this.nSugarPackets + " packets, Creams = " + this.nCreams + " splashes of cream, Cups = " + this.nCups + " cups.");
}
// values of Parameter (in this case all ints) decrease
this.nCoffeeOunces -= size;
this.nSugarPackets -= nSugarPackets;
this.nCreams -= nCreams;
this.nCups -= -cupsRequested;
System.out.println("Here is your order of" + size + " oz coffee with " + nSugarPackets + " sugar packets and " + nCreams + " pumps of cream. Have a great day!");
if (cupsRequested== 1){
System.out.println("Here is your order of" + size + " oz coffee with " + nSugarPackets + " sugar packets and " + nCreams + " splashes of cream. Enjoy!");
}
else {
System.out.println("Here are your orders of" + cupsRequested + " " + size + " oz coffees with " + nSugarPackets + " sugar packets and " + nCreams + " splashes of cream. Enjoy!");
}
}
// if the house has an elevator
public void goToFloor(int floorNum) {
super.goToFloor(activeFloor);
if (floorNum == 1){
System.out.println("You are now on " + floorNum + ".");
}
else{
System.out.println("Cannot go to " + floorNum + " -- for employees only. Sorry.");
}
}
public void showOptions() {
super.showOptions();
System.out.println("Available options at " + this.name + ":\n + enter() \n + exit() \n + sellCoffee(size, nSugarPackets, nCreams)");
}
public static void main(String[] args) {
Cafe Compass= new Cafe(12, 3, 4, 1, "Compass Cafe", "3 Bake St.", 2);
}
}