Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit d81016e4 authored by 65160029's avatar 65160029
Browse files

add class Cat

parent 6991d33a
No related branches found
No related tags found
No related merge requests found
public class Cat extends Pet {
public Cat() {
super();
// TODO Auto-generated constructor stub
}
public Cat(String name, String color) {
super(name, color);
// TODO Auto-generated constructor stub
}
@Override
public String voice() {
// TODO Auto-generated method stub
return "Meow Meow";
}
}
......@@ -2,8 +2,8 @@
public class Main {
public static void main(String[] args) {
Pet p = new Dog("Luffy","Brown");
System.out.println("Dog name is "+ p.getName() + " color is " + p.getColor()+" sound is " + p.voice());
Pet p = new Cat("Booky","Gray");
System.out.println("Cat name is "+ p.getName() + " color is " + p.getColor()+" sound is " + p.voice());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment