Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ergastirio2;
- public class Cat {
- public static int maxFood = 5;
- public int food;
- public String name;
- public boolean dead;
- public boolean isDead() {
- return this.dead;
- }
- public void meou() {
- if (!this.isDead()) {
- if (this.food > 0) {
- System.out.println(">>" + this.name + ": meaouuuuuu");
- this.food -= 1;
- } else {
- this.pour();
- }
- }
- }
- public void pour() {
- if (!this.isDead()) {
- System.out.println(">>" + this.name + ": pouuuurrrrrr");
- }
- }
- public void feed(int food) {
- if (!this.isDead()) {
- if (food > maxFood) {
- System.out.println("BAM");
- this.dead = true;
- } else if (food <= 0) {
- this.pour();
- } else {
- this.food = food;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement