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
Perceptron simplest definition
Aleks [24]

Answer:

A perceptron is a neural network with a single layer

4 0
3 years ago
to allow excel to change the cell references in a formula or function from row to row or column to column as you fill with it, y
posledela

to allow excel to change the cell references in a formula or function from row to row or column to column as you fill with it, you must use an formula cells.

8 0
3 years ago
How to create drop down list in excel with multiple selections.
Art [367]

Answer: <em>Select the cell or cells you want the drop-down list to appear in.</em>

<em>Click on the Data tab on Excel's ribbon.</em>

<em>Click on the Data Validation button in the Data Tools group.</em>

<em>In the Data Validation dialog, in the Allow: list select List.</em>

<em>Click in the Source: box.</em>

<em />

<em></em>

<em />

8 0
3 years ago
Read 2 more answers
Caches are important to providing a high-performance memory hierarchy to processors. Below is a list of 32-bits memory address r
LiRa [457]

Answer:

See explaination

Explanation:

please kindly see attachment for the step by step solution of the given problem.

5 0
3 years ago
The World Wide Web is full of unstructured data. Search engines like Google, Bing and Yahoo have been doing a good job of allowi
bija089 [108]

Answer: Query

Explanation:

The Search Criteria is entered and any when a related Query is logged, it speedily bring out the linked details for exploration.

5 0
3 years ago
Other questions:
  • Read each scenario, and then select the best wireless device for the worker’s needs. A trucker is constantly on the road. He fre
    8·2 answers
  • QUESTION
    10·1 answer
  • T FROW PYCW GCYN TA T ODYHP WQROW TW<br><br> Someone decode pls
    14·1 answer
  • A lamp outside a front door comes on automatically when it is dark, and when someone stands on the doormat outside the front doo
    7·1 answer
  • Once secured a wheelchair may move up to 6 inches in any direction
    6·1 answer
  • Explain the three schemes via which the binding of instructions and data to memory addresses can be done. In each scheme, how th
    13·1 answer
  • Help plz!! I will mark brainliest
    15·2 answers
  • Which of the following statements best illustrates how value was created for eggs? when a farmer sells a chicken who is no longe
    9·1 answer
  • Compare mini and mainframe computer in terms of speed,memory and storage​
    15·1 answer
  • What is my mistake on this code? (Python)
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!