Home > Back-end >  Java
Java

Time:09-24

Emergency help
1. Implement a Cat (Cat), define "varieties (name)", "age (age)," "feature (pro)" three variables, set the three information of object, getAllInfo () to display all information,
2. The interface implementation of polymorphic: Animal interface, two abstract methods: call cry () and eat eat (), class implements the interface,

CodePudding user response:

Is to implement a animal interface, the realization of a cat, then realize the cry and eat

CodePudding user response:

reference 1/f, Simple, Soft reply:
is a animal interface, implement a specific cat, then realize the cry and eat

Er... The specific procedures can't write??????

CodePudding user response:

 
Interface Animal {

Void cry ();
Void the eat ();
}

The class implements Cat Animal {

private String name;
private int age;
Private String pro;

@ Override
Public void cry () {

}

@ Override
Public void eat () {

}

Public void getAllInfo () {
System. The out. Printf (" varieties: % s \ t age: % d \ t characteristics: % s ", name, age, pro);
}
}