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
What percentage of teens plays video games?<br><br> A.97%<br> B.100%<br> C.74%<br> D.50%
inna [77]

Answer:

This would all depend on what kind of video games you are talking about, most people would say that playing on you phone is like playing a game on a console or a PC.  

most kids do play on these three things, so I'm going to go with answer choice C.

Explanation:

Reason why is because just like there are many who play, there are many who don't. I being one who prefers to read would like to make it known that not all teens do play video games, and that there are plenty of those who would rather do something productive.

7 0
3 years ago
Read 2 more answers
Which focal length and aperture combination is most likely to give you a deep depth of field?
frutty [35]

Answer:

f/11 is the answer I think

3 0
3 years ago
You are writing an email to a potentional employer about a job opportunity. What can you do to make sure the email reflects your
Lina20 [59]
You want to use proper etiquette and be polite, do not call them by their first name and always refer to them as Mr., or Mrs. Use an extended vocabulary and do not talk about yourself.  If you have proper grammar, depending on the job, that can be seen as intelligence. And always use an appropriate closing that is respectful. Such as, Sincerely, John Doe.
4 0
3 years ago
Read 2 more answers
ICD-10-CM diagnosis codes are entered in Block 21 of the CMS-1500 claim. A maximum of __________ ICD-10- CM codes may be entered
SVETLANKA909090 [29]

Answer:

The answer to this question is 12.

Explanation:

You can enter a maximum of 12 ICD-10-CM codes on a single claim.Since we know that the codes entered in CMS-1500 claim are in the block of 21 in ICD-10-CM diagnosis.This should be kept in mind always in medical insurance.

So we conclude that the answer to this question is 12.

5 0
3 years ago
A graphic on-screen image representing an object or an idea is called a(n) A. menu. B. image. C. graphic. D. icon.
kap26 [50]
It's called D. icon
We often see these icons on our desktop page as soon as we logged on to our personal computer.
The icon on the destkop will acted as a short-cut that will opened up and connected us with the program simply by clicking the icon.
8 0
3 years ago
Read 2 more answers
Other questions:
  • "Dean wants a quick way to look up staff members by their Staff ID. In cell Q3, nest the existing VLOOKUP function in an IFERROR
    10·1 answer
  • In Outlook 2016, what are the three format options when sending an email message? Check all that apply.
    7·1 answer
  • You’re responding to a troubleshooting ticket about a laser printer in HR that isn’t working. According to reports, the printer
    7·1 answer
  • How can I identify what is and what isn't an IP Address?
    5·1 answer
  • List the five parts of a system.describe them.
    13·1 answer
  • How to execute python code in command prompt *window*?
    5·1 answer
  • What are price comparison websites?
    6·1 answer
  • For 8.6 code practice: Question 1 It keeps says it's an infinite loop and it will not work can someone give me the code that wil
    9·1 answer
  • Alayna is researching information online to write her essay about the Berlin Wall.
    8·1 answer
  • Who benefits the most from billing by the second for cloud resources, such as virtual machines?.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!