Computers and Technology, 12.03.2021 16:00, gracedaniels68
The cat store needs your help! The base class Animal has private fields animalName, and animalAge. The derived class Cat extends the Animal class and includes a private field for catBreed. Complete main() to:
create a generic animal and print information using printInfo().
create a Cat animal, use printInfo() to print information, and add a statement to print the cat's breed using the getBreed() method.
Ex. If the input is:
Dobby
2
Kreacher
3
Maine Coon
the output is:
Pet Information:
Name: Dobby
Age: 2
Pet Information:
Name: Kreacher
Age: 3
Breed: Maine Coon
AnimalIformation. java
import java. util. Scanner;
public class AnimalInformation {
public static void main(String[] args) {
Scanner scnr = new Scanner(System. in);
Animal myAnimal = new Animal();
Cat myCat = new Cat();
String animalName, catName, catBreed;
int animalAge, catAge;
animalName = scnr. nextLine();
animalAge = scnr. nextInt();
scnr. nextLine();
catName = scnr. next();
catAge = scnr. nextInt();
scnr. nextLine();
catBreed = scnr. nextLine();
// TODO: Create generic animal (using animalName, animalAge) and then call printInfo
// TODO: Create cat animal (using catName, catAge, catBreed) and then call printInfo
// TODO: Use getBreed(), to output the breed of the cat
}
}
Animal. java
public class Animal {
protected String animalName;
protected int animalAge;
public void setName(String userName) {
animalName = userName;
}
public String getName() {
return animalName;
}
public void setAge(int userAge) {
animalAge = userAge;
}
public int getAge() {
return animalAge;
}
public void printInfo() {
System. out. println("Animal Information: ");
System. out. println(" Name: " + animalName);
System. out. println(" Age: " + animalAge);
}
}
Cat. java
public class Cat extends Animal {
private String catBreed;
public void setBreed(String userBreed) {
catBreed = userBreed;
}
public String getBreed() {
return catBreed;
}
}
Answers: 2
Computers and Technology, 21.06.2019 22:30, mariahernandez237503
Provide an example of a project that combines the three principles of lean six sigma with business project management (bpm) and services oriented architecture (soa). identify the elements of the project that comply with each of three principles.
Answers: 1
Computers and Technology, 23.06.2019 17:00, ayoismeisjjjjuan
The camera still is bad even with the new iphone xr and especially in low light it is even worst because you can see the pixels more if its in low light. if all you apple customers want apple to fix this then lets fill there feedback with complaints about the can apple do to fix this issue?
Answers: 1
The cat store needs your help! The base class Animal has private fields animalName, and animalAge. T...
Business, 29.01.2020 12:04
Mathematics, 29.01.2020 12:04
History, 29.01.2020 12:04
Mathematics, 29.01.2020 12:04