Last active
August 29, 2015 13:56
-
-
Save GrantSchiller/9086966 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Cup implements Replenishable { | |
private int capacity; | |
private int amount; | |
public Cup(int c){ | |
capacity = c; | |
amount = 0; | |
} | |
public void fill(int foo) { | |
if foo + amount > capacity { | |
amount = 0; | |
} else { | |
amount += foo; | |
} | |
} | |
public void empty(int foo) { | |
if amount - foo >= 0 { | |
amount -= foo; | |
} | |
} | |
public String checkAmount(){ | |
System.out.println(amount); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person implements Replenishable { | |
private int capacity; | |
private int amount; | |
public Person(int c){ | |
capacity = c; | |
amount = 0; | |
} | |
public void fill(int foo) { | |
if foo + amount > capacity { | |
amount = 0; | |
System.out.println("*BLARGH* ... I just threw up."); | |
} else { | |
amount += foo; | |
System.out.println("Yum! That tasted good.") | |
} | |
} | |
public void empty(int foo) { | |
if amount - foo >= 0 { | |
amount -= foo; | |
System.out.println("I just pooped."); | |
} | |
} | |
public String checkAmount(){ | |
if (amount > 7){ | |
System.out.println("I feel full."); | |
} else if (amount > 5) { | |
System.out.println("I feel pretty darn satiated."); | |
} else if (amount > 3){ | |
System.out.println("I feel a bit hungry."); | |
} else { | |
System.out.println("I am starving."); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Replenishable { | |
void fill(int amount); | |
void empty(int amount); | |
String checkAmount(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment