1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Allushta [10]
2 years ago
9

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;
}
}
Computers and Technology
1 answer:
Nat2105 [25]2 years ago
8 0

Answer:

Answered below

Explanation:

//TODO1

myAnimal.setName(animalName);

myAnimal.setAge(animalAge);

myAnimal.printInfo();

//TODO2

myCat.setName(catName);

myCat.setAge(catAge);

myCat.setBreed(catBreed);

myCat.printInfo();

//TODO

//Call the getter method of the cat class and //save the returned string in a variable to print //it out.

String breed = myCat.getBreed();

System.out.print(breed);

You might be interested in
Select two netiquette guidelines. In a paragraph of no less than 125 words, explain why these guidelines make professional onlin
Paladinen [302]

Respect others.

This means that it is important to make sure that your interactions with other internet users are based on respect for each other's resources. This includes time, bandwidth, and even emotions. Ensure that the information you are sharing is of value to the intended recipients and is sent in a timely manner. Treat other online users as you'd have them treat you.

Visualize your online conversations as you would real life conversations. Avoid being offensive and be accommodating of other peoples shortcomings. Also keep in mind who is part of the forum you are interacting with so as to use appropriate language. 



4 0
2 years ago
You are building a computer from spare parts in the office. You build the computer and realize you have several different types
san4es73 [151]

Answer:

The pin count is the same

Explanation:

5 0
2 years ago
You should always buy the biggest camera bag that you can find for extra equipment.
Akimi4 [234]

Answer:

true

Explanation:

7 0
2 years ago
Read 2 more answers
I need help. People who know computer science. I have selected a word from the first 1000 words in my dictionary. Using the bina
Rudiy27

Answer:

14

Explanation:

8 0
2 years ago
The list below show test scores for 3rd period on a recent test.
Serhud [2]

Answer:

dshfjkahsdfkjhasdkjfasd

Explanation:

this is what u get for doing this to others foool

6 0
3 years ago
Other questions:
  • Which organization publishes a handbook that describes various occupations?
    12·1 answer
  • How can you clean out the scales in an electric iron without taking the iron apart? A. By rinsing the tank and holes with a wate
    12·2 answers
  • Computers are not just stand-alone desktop machines anymore. They are often embedded in common appliances and technology that we
    6·1 answer
  • Create a class 'ProblemSolution' with following characteristics A public method 'solution' without parameters and return type is
    14·1 answer
  • Fill in the blank with the correct response.
    10·1 answer
  • A computer virus is a program that can copy itself and infect a computer without the permission of the owner. How do you think a
    9·1 answer
  • Write a couple of paragraphs about the usefulness of computer​
    5·1 answer
  • Which of the following defines a computer program?
    14·1 answer
  • k-means clustering cannot be used to perform hierarchical clustering as it requires k (number of clusters) as an input parameter
    15·1 answer
  • When the CPU performs the work described in the commands,
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!