Denis_Hristov

HomeworkConstructorCat

Oct 5th, 2021 (edited)
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. public class Cat {
  2.     String name = "Gosho";      //suzdavame pole s ime
  3.     String color = "Black";     //suzdavame pole s cvqt
  4.     int age = 3;                //suzdavame pole s godini
  5.  
  6.     public Cat() {                   //default constructor
  7.         this.name = name;
  8.         this.color = color;
  9.         this.age = age;
  10.     }
  11.  
  12.     public Cat(String name, String color, int age) {          //constructor with parameters
  13.         this.name = name;
  14.         this.color = color;
  15.         this.age = age;
  16.     }
  17.  
  18.     public void CatEating(){                                 //method pokazvasht che kotkata qde
  19.         System.out.println("The cat is eating!");
  20.     }
  21.  
  22.     public void CatSleeping(){                               //method pokazvasht che kotkata spi
  23.         System.out.println("The cat is sleeping!");
  24.     }
  25.  
  26.     public void LionEating(){                                //method pokazvasht che luva qde
  27.         System.out.println("The lion is eating!");
  28.     }
  29.  
  30.     public void LionSleeping(){                              //method pokazvasht che luva spi
  31.         System.out.println("The lion is sleeping!");
  32.     }
  33. }
  34.  
Add Comment
Please, Sign In to add comment