HarrJ

B8 Day 16 Animals sample

Sep 28th, 2022 (edited)
1,162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. package mattroseb8wk3;
  2.  
  3. public class Day16A {
  4.     public static void main(String[] args) {
  5.         Aspin callAspin = new Aspin();
  6.         callAspin.animalActions();
  7.     }
  8. }
  9.  
  10. class Animal {
  11.     void animalActions() {
  12.         classification();
  13.         makeSound();
  14.         move();
  15.         eating();
  16.     }
  17.    
  18.     void classification() {
  19.         System.out.println("It is a mammal");
  20.     }
  21.    
  22.     void makeSound() {
  23.         System.out.println("The animal is making sounds");
  24.     }
  25.    
  26.     void move() {
  27.         System.out.println("Its moving on its 4 legs");
  28.     }
  29.    
  30.     void eating() {
  31.         System.out.println("It is an omnivore");
  32.     }
  33. }
  34.  
  35. class Aspin extends Animal {
  36.     @Override
  37.     void animalActions() {
  38.         System.out.println("An Aspin are:");
  39.         super.animalActions(); //To change body of generated methods, choose Tools | Templates.
  40.     }
  41.    
  42.     @Override
  43.     void makeSound() {
  44.         System.out.println("Arf Arf Arf");
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment