summaryrefslogtreecommitdiffstats
path: root/Java/Cup/Cup.java
diff options
context:
space:
mode:
authormsglm <msglm@techchud.xyz>2023-01-14 05:31:48 -0600
committermsglm <msglm@techchud.xyz>2023-01-14 05:31:48 -0600
commit9d53d8857eaa1c9405894a88ca75bc4657e42f35 (patch)
treeeb1efc1d028b949dd83bb710c68be8eff58f26e7 /Java/Cup/Cup.java
downloadschool-code-master.tar.gz
school-code-master.tar.bz2
school-code-master.zip
Inital CommitHEADmaster
Diffstat (limited to 'Java/Cup/Cup.java')
-rw-r--r--Java/Cup/Cup.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/Java/Cup/Cup.java b/Java/Cup/Cup.java
new file mode 100644
index 0000000..c313c07
--- /dev/null
+++ b/Java/Cup/Cup.java
@@ -0,0 +1,55 @@
+public class Cup {
+
+ // data member
+ private double capacity;
+ private double holding;
+ private String color;
+
+
+
+ // Constructors
+ public Cup(double c, String co, double h) {
+ capacity = c;
+ color = co;
+ holding = h;
+ }
+ public Cup() {
+ color = "red";
+ capacity = 16;
+ holding = 0;
+ }
+ // set
+ public void fillCup(double h) {
+ if (h > capacity){
+ capacity = holding;
+ } else {
+ holding = holding + h;
+ }
+ }
+ public void sip() {
+ if(holding - 1 < 1){
+ holding = holding-1;
+ } else {
+ //System.out.println("CUPPER UNDERFLOW DETECTED");
+ }
+ }
+
+ public void gulp() {
+ if(holding-3 > 1){
+ holding = holding-3;
+ } else {
+ //System.out.println("CUPPER UNDERFLOW DETECTED");
+ }
+ }
+ public void emptyCup() {
+ holding = 0;
+ }
+
+ // modify and return
+ public String status() {
+ return capacity + " ounce " + color + " cup that contains " + holding + " ounce[s].";
+ }
+
+}
+
+