Guest User

Untitled

a guest
Nov 25th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. //Fish.java
  2. public class Fish extends Pet {
  3.    
  4. int currentDepth=0;
  5.  
  6. public int dive(int howDeep) {
  7. currentDepth=currentDepth + howDeep;
  8. System.out.println("Ныряю на глубину " + howDeep + " футов");
  9. System.out.println("Я на глубине " + currentDepth + " футов ниже уровня моря");
  10. return currentDepth;
  11.     }
  12.  
  13. public String say(String something){
  14. return "Ты что не знаешь, что рыбы не разговаривают?";
  15.     }
  16. }
  17.  
  18. //FishMaster.java
  19.  
  20. public class FishMaster {
  21. public static void main(String[] args) {
  22. Fish myFish = new Fish();
  23. myFish.dive(2);
  24. myFish.dive(3);
  25. myFish.sleep();
  26. myFish.say("Привет");
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment