Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. package ergastirio2;
  2. public class Cat {
  3. public static int maxFood = 5;
  4. public int food;
  5. public String name;
  6. public boolean dead;
  7. public boolean isDead() {
  8. return this.dead;
  9. }
  10. public void meou() {
  11.  
  12. if (!this.isDead()) {
  13. if (this.food > 0) {
  14. System.out.println(">>" + this.name + ": meaouuuuuu");
  15. this.food -= 1;
  16. } else {
  17. this.pour();
  18. }
  19. }
  20. }
  21. public void pour() {
  22. if (!this.isDead()) {
  23. System.out.println(">>" + this.name + ": pouuuurrrrrr");
  24. }
  25. }
  26. public void feed(int food) {
  27. if (!this.isDead()) {
  28. if (food > maxFood) {
  29. System.out.println("BAM");
  30. this.dead = true;
  31. } else if (food <= 0) {
  32. this.pour();
  33. } else {
  34. this.food = food;
  35. }
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement