votako

pets

Dec 11th, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. package Pets;
  2.  
  3. public class Pet {
  4.     int age;
  5.     float weidth;
  6.     float height;
  7.     String color;
  8.  
  9.     public void sleep(){
  10.         System.out.println("good night");
  11.     }
  12.     public void eat(){
  13.         System.out.println("i'm very hungry");
  14.     }
  15.     public String say(String aWord){
  16.         return "then i say: " + aWord;
  17.     }
  18. }
  19.  
  20.  
  21.  
  22. package Pets;
  23.  
  24. public class Fish extends Pet {
  25.     int currentDepth=0;
  26.     public int drive(int howDeep){
  27.         currentDepth = currentDepth+howDeep;
  28.         if (currentDepth>100){
  29.             System.out.println("can't drive! it's too deep!");
  30.             currentDepth=currentDepth-howDeep;
  31.         }
  32.         else {
  33.             System.out.println("drive on deep "+howDeep+"m.");
  34.             System.out.println("i'm on deep " + currentDepth
  35.                     +" lover them water");
  36.         }
  37.         return currentDepth;
  38.     }
  39.     public String say(String somesing){
  40.         return "pff, i can't talk!";
  41.     }
  42. }
  43.  
  44.  
  45.  
  46.  
  47.  
  48. package Pets;
  49. import out.*;
  50.  
  51. public class PetMaster {
  52.     public static void main(String[] args){
  53.  
  54.         Fish fifi = new Fish();
  55.         fifi.drive(142);
  56.         fifi.say("hey");
  57.  
  58.  
  59.  
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment