Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Pets;
- public class Pet {
- int age;
- float weidth;
- float height;
- String color;
- public void sleep(){
- System.out.println("good night");
- }
- public void eat(){
- System.out.println("i'm very hungry");
- }
- public String say(String aWord){
- return "then i say: " + aWord;
- }
- }
- package Pets;
- public class Fish extends Pet {
- int currentDepth=0;
- public int drive(int howDeep){
- currentDepth = currentDepth+howDeep;
- if (currentDepth>100){
- System.out.println("can't drive! it's too deep!");
- currentDepth=currentDepth-howDeep;
- }
- else {
- System.out.println("drive on deep "+howDeep+"m.");
- System.out.println("i'm on deep " + currentDepth
- +" lover them water");
- }
- return currentDepth;
- }
- public String say(String somesing){
- return "pff, i can't talk!";
- }
- }
- package Pets;
- import out.*;
- public class PetMaster {
- public static void main(String[] args){
- Fish fifi = new Fish();
- fifi.drive(142);
- fifi.say("hey");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment