Advertisement
Denis_Hristov

HomeworkConstructorCat1

Oct 5th, 2021
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. public class Cat1 {
  2.     public static void main(String[] args) {
  3.         Cat MyCat = new Cat();                                             //suzdavame obekt ok class Cat
  4.         Cat MyLion = new Cat("Grisho", "yellow", 5);                       //suzdavame vtori obekt ot class Cat
  5.                                                                            //koito e s parametri v constructora
  6.  
  7.         System.out.println("The cat's name is: " + MyCat.name);            //printirame poletata i metodite na obekt 1
  8.         System.out.println("The cat's color is: " + MyCat.color);
  9.         System.out.println("The cat's age is: " + MyCat.age);
  10.  
  11.         System.out.println();
  12.  
  13.         MyCat.CatEating();
  14.         MyCat.CatSleeping();
  15.  
  16.         System.out.println();
  17.         System.out.println();
  18.  
  19.         System.out.println("The cat's name is: " + MyLion.name);           //printirame poletata i metodite na obekt 2
  20.         System.out.println("The cat's color is: " + MyLion.color);
  21.         System.out.println("The cat's age is: " + MyLion.age);
  22.  
  23.         System.out.println();
  24.  
  25.         MyCat.LionEating();
  26.         MyCat.LionSleeping();
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement