Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import jdk.jfr.ContentType;
- public class Bottle {
- //PROPERTIES
- private int BOTTLE_CAPACITY;
- private int BOTTLE_CONTENT;
- private String BOTTLE_NAME;
- //CONSTRUCTOR
- //GETTERS & SETTERS
- public int getBottleCapacity() {
- return BOTTLE_CAPACITY;
- }
- public int getBottleContent() {
- return BOTTLE_CONTENT;
- }
- //METHODS
- public boolean isEmpty() {
- return BOTTLE_CONTENT != 0;
- }
- public void emptyBottle() { this.BOTTLE_CONTENT = 0; }
- public void fillBottle() { this.BOTTLE_CONTENT = BOTTLE_CAPACITY; }
- public void transfer(Bottle ReceptionBottle){
- while(this.BOTTLE_CONTENT != 0 && ReceptionBottle.BOTTLE_CONTENT != ReceptionBottle.BOTTLE_CAPACITY){
- this.BOTTLE_CONTENT --;
- ReceptionBottle.BOTTLE_CONTENT ++;
- }
- }
- public boolean equals(Bottle bottle){
- boolean equals = false;
- if (this.BOTTLE_CONTENT == bottle.BOTTLE_CONTENT && this.BOTTLE_CAPACITY == bottle.BOTTLE_CAPACITY && this.BOTTLE_NAME == bottle.BOTTLE_NAME){
- return equals = true;
- }
- }
- @Override
- public String toString(){
- return "Nom : " + BOTTLE_NAME + ", contenu: " + BOTTLE_CONTENT + "L, capacité max: " + BOTTLE_CAPACITY + "L. ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement