Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. import jdk.jfr.ContentType;
  2.  
  3. public class Bottle {
  4.  
  5. //PROPERTIES
  6.  
  7. private int BOTTLE_CAPACITY;
  8. private int BOTTLE_CONTENT;
  9. private String BOTTLE_NAME;
  10.  
  11. //CONSTRUCTOR
  12.  
  13.  
  14. //GETTERS & SETTERS
  15.  
  16. public int getBottleCapacity() {
  17. return BOTTLE_CAPACITY;
  18. }
  19.  
  20. public int getBottleContent() {
  21. return BOTTLE_CONTENT;
  22. }
  23.  
  24. //METHODS
  25.  
  26. public boolean isEmpty() {
  27. return BOTTLE_CONTENT != 0;
  28. }
  29.  
  30. public void emptyBottle() { this.BOTTLE_CONTENT = 0; }
  31.  
  32. public void fillBottle() { this.BOTTLE_CONTENT = BOTTLE_CAPACITY; }
  33.  
  34. public void transfer(Bottle ReceptionBottle){
  35. while(this.BOTTLE_CONTENT != 0 && ReceptionBottle.BOTTLE_CONTENT != ReceptionBottle.BOTTLE_CAPACITY){
  36. this.BOTTLE_CONTENT --;
  37. ReceptionBottle.BOTTLE_CONTENT ++;
  38. }
  39. }
  40.  
  41.  
  42. public boolean equals(Bottle bottle){
  43. boolean equals = false;
  44. if (this.BOTTLE_CONTENT == bottle.BOTTLE_CONTENT && this.BOTTLE_CAPACITY == bottle.BOTTLE_CAPACITY && this.BOTTLE_NAME == bottle.BOTTLE_NAME){
  45. return equals = true;
  46. }
  47. }
  48.  
  49. @Override
  50. public String toString(){
  51. return "Nom : " + BOTTLE_NAME + ", contenu: " + BOTTLE_CONTENT + "L, capacité max: " + BOTTLE_CAPACITY + "L. ";
  52. }
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement