Advertisement
nadejdachitakova

1aLion

Feb 17th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public class Lion extends Animal {
  2.  
  3. private boolean isKingOfTheJungle;
  4.  
  5. public boolean isKingOfTheJungle() {
  6. return isKingOfTheJungle;
  7. }
  8.  
  9. public void setKingOfTheJungle(boolean isKingOfTheJungle) {
  10. if(getGender() != null &&
  11. getGender().equals("male"))
  12. this.isKingOfTheJungle = isKingOfTheJungle;
  13. }
  14.  
  15. public Lion(int cell) {
  16. super(Lion.class.getSimpleName(), cell);
  17. }
  18.  
  19. @Override
  20. public void move(String from, String to) {
  21. System.out.println("Walked from " + from
  22. + " to " + to);
  23.  
  24. if(getGender() != null &&
  25. getGender().equals("male")) {
  26. System.out.println("And slept for 20 hours");
  27. }
  28. }
  29.  
  30. @Override
  31. public void eat() {
  32. System.out.println("Eats tasty meat!"
  33. + " (or vegans if there"
  34. + " are any around :D )");
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement