Advertisement
Fourteen98

Classes

Sep 12th, 2021
766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. package com.company;
  2.  
  3. public class Birds {
  4.     // features of Birds : color, size, name, weight;
  5.     String color;
  6.     double size;
  7.     String name;
  8.     double weight;
  9.  
  10.  
  11.     // functions of  Birds: Flying, Hopping, walking, breathing, eating, hovering;
  12.     void Flying(){
  13.         System.out.println("I can fly");
  14.     }
  15.  
  16.     void Hopping(){
  17.         System.out.println("I can hop");
  18.     }
  19.  
  20.     void Walking(){
  21.         System.out.println("I can walk");
  22.     }
  23.  
  24.     void Breathing(){
  25.         System.out.println("I can breath");
  26.     }
  27.  
  28.     void Hovering(){
  29.         System.out.println("I can hover");
  30.     }
  31.  
  32.     void Eating(){
  33.         System.out.println("I can eat");
  34.     }
  35.  
  36.  
  37.  
  38.     public static void main(String[] args) {
  39.         Birds eagle = new Birds();
  40.         Birds parrot = new Birds();
  41.         Birds hummingbird = new Birds();
  42.         Birds flamingo = new Birds();
  43.  
  44.         eagle.name = "Golden Eagle";
  45.         eagle.color = "black";
  46.         eagle.size = 3.4;
  47.         eagle.weight = 10;
  48.  
  49.  
  50.         eagle.Flying();
  51.         eagle.Walking();
  52.        
  53.         parrot.Eating();
  54.  
  55.  
  56.  
  57.  
  58.     }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement