MilaDimitrovaa

Cat-Homework

Oct 7th, 2021 (edited)
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. package com.company;
  2.  
  3. public class Cat {
  4.     private String name;
  5.     private String color;
  6.     private int age;
  7.  
  8.     static void foodCat(){
  9.         System.out.println("The cat eats!");
  10.     }
  11.  
  12.     static void sleepCat(){
  13.         System.out.println("The cat sleep!");
  14.     }
  15.  
  16.     public Cat(){
  17.         this.name = "Unnamed";
  18.         this.color = "grey";
  19.         this.age = 0;
  20.     }
  21.  
  22.     public Cat(String name1,String color1,int age1){
  23.         this.name = name1;
  24.         this.color = color1;
  25.         this.age = age1;
  26.     }
  27.  
  28.  
  29.  
  30.     @Override
  31.     public String toString() {
  32.         return "Cat --> " +
  33.                 "name = " + name  +
  34.                 ", color = " + color +
  35.                 ", age = " + age ;
  36.     }
  37. }
  38.  
Add Comment
Please, Sign In to add comment