subject

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;
}
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:30
Ayear in the modern gregorian calendar consists of 365 days. in reality, the earth takes longer to rotate around the sun. to account for the difference in time, every 4 years, a leap year takes place. a leap year is when a year has 366 days: an extra day, february 29th. the requirements for a given year to be a leap year are: the year must be divisible by 4if the year is a century year (1700, 1800, the year must be evenly divisible by 400some example leap years are 1600, 1712, and 2016.write a program that takes in a year and determines whether that year is a leap year.ex: if the input is 1712, the output is: 1712 is a leap year.ex: if the input is 1913, the output is: 1913 is not a leap year.
Answers: 2
question
Computers and Technology, 22.06.2019 21:50
Given int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 counting numbers, and store this value in total. thus your code should put 11 + 22 + 33 + + 4949 + 50*50 into total. use no variables other than k and total.
Answers: 2
question
Computers and Technology, 23.06.2019 03:00
State 7 common key's for every keyboard
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
To become an audio technician, the most successful tactics might include the following. (select all that apply). learning how to persuade other people gaining different types of experience in audio technology learning as much as possible about art history establishing a reputation as a reliable professional
Answers: 1
You know the right answer?
The cat store needs your help! The base class Animal has private fields animalName, and animalAge. T...
Questions
question
Mathematics, 19.11.2020 22:00
question
Social Studies, 19.11.2020 22:00
question
Mathematics, 19.11.2020 22:00
question
Mathematics, 19.11.2020 22:00
question
Social Studies, 19.11.2020 22:00
Questions on the website: 13722360