HarrJ

Day 15 3

Aug 16th, 2023
1,236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. package week3;
  2.  
  3. public class Day15F {
  4.     public static void main(String[] args) {
  5.         GoldFish callGoldFish = new GoldFish();
  6.        
  7.         callGoldFish.summary();
  8.     }
  9. }
  10.  
  11. abstract class Animal2 {
  12.     abstract void animalInfo();
  13.     abstract void movement();    
  14.     abstract void eat();    
  15.     abstract void makeSound();
  16.    
  17.     void summary() {
  18.         animalInfo();
  19.         movement();
  20.         eat();
  21.         makeSound();
  22.     }
  23. }
  24.  
  25. class GoldFish extends Animal2 {
  26.     @Override
  27.     void animalInfo(){
  28.         System.out.println("Goldfish are a freshwater fish");
  29.     }
  30.    
  31.     @Override
  32.     void movement() {
  33.         System.out.println("A Goldfish swims");
  34.     }
  35.    
  36.     @Override
  37.     void eat() {
  38.         System.out.println("It will happily eat anything");
  39.     }
  40.    
  41.     @Override
  42.     void makeSound() {
  43.         System.out.println("It doesn't make any sounds");
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment