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
Evaluate if the following function is a good candidate to be placed in a library. Why or why not?
Anastaziya [24]

Answer:

No, this would not be a good candidate because it can't be used in creating new programs.

Explanation:

^

8 0
2 years ago
Read 2 more answers
Server virtualization in windows server 2012 r2 is based on a module called the
alexgriva [62]
<span>Server virtualization in windows server 2012 r2 is based on a module called the</span> hypervisor.
3 0
3 years ago
Explain why the network administrator uses the hexadecimal
fomenos

Answer:

The main reason why we use hexadecimal numbers is because it provides a more human-friendly representation and is much easier to express binary number representations in hex than it is in any other base number system. Computers do not actually work in hex. Lets take an example, using a byte.

Hope this answer is right!!

5 0
3 years ago
Keep true , never be ashamed of doing right decide on what you think is right and stick to it.
Doss [256]
This is the quote of T.S. Eilot
5 0
3 years ago
To annotate a document with a remark for another reviewer to address, select the _____ feature. comments track changes annotatio
kupik [55]
Select the comments feature.

We use comments in our documents to track issues for follow up or make suggestions to other people. A comment is inserted inside a balloon or a box that appears in the document's margins. Whatever the situation you may be in, you can easily add comments in a word document.

 



6 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following is an important initial step in designing an interface
    7·1 answer
  • How can a network design project benefit from the principles of itsm? How might itsm impede a network design project?
    11·1 answer
  • Your friend Suzy calls to ask for help with her computer. She says when she first turns on the computer, she doesn’t hear a spin
    10·1 answer
  • Information is best described as
    10·1 answer
  • What year did the first hovercraft sail on water
    15·1 answer
  • U $ er Ideas for R 0 B 1 0 X?
    12·2 answers
  • Your task is to implement a function replace_once(t, d), that takes a text t and a replacement dictionary d, and returns the res
    10·1 answer
  • Whats the formatting of a letter to the editor?​
    12·1 answer
  • Each drop-down menu.
    8·1 answer
  • Design algorithm and the corresponding flow chart for adding the subject score of 5, total value and rank.​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!