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
Janice has decided that the best approach to programming a new social media app is to start with a small portion of it by writin
Maru [420]

Answer:

blacc

bhhj

Explanation:

4 0
3 years ago
What is the term of social media
seraphim [82]
It is used to describe a variety of web based platforms, applications, and technologies that allow people to socially interact online.
3 0
3 years ago
Which of the following likely comes last in developing a presentation outline
kari74 [83]
So in developing a presentation outline, the first thing that we are going to do is to introduce what it is all about. This means that the main points come first. After the main points, follow the sub points. The sub points serve as the explanation of the main points. After the sub points are the illustrations and examples. These are already the specifics which support the sub points and the main points. Therefore, the answer is A.
8 0
3 years ago
Read 2 more answers
A series of drawn pictures (like a comic) of key visual shots of planned production for video is a/an
Ne4ueva [31]

Answer:

The correct answer is <u>D) Storyboard</u>

Explanation:

A storyboard is used during the initial planning stage of filmmaking. You draw pictures to demonstrate the general idea of what shots you want to get before actually going out and filming on a set/studio.

4 0
2 years ago
Which of the following is not a basic networking hardware component? Network interface card
RideAnS [48]

Answer:

Device Driver

Explanation:

All of the other options are physical and are something that you can physically touch. The device driver runs in software and allows the computer to communicate with the device that is attached.

4 0
3 years ago
Other questions:
  • These devices: monitor, earphone, speakers are examples of what? Input devices Storage devices Output devices All answer are cor
    10·2 answers
  • One type of technology that can verify a person's identity is _____.
    6·2 answers
  • When using the boolean data type, we encapsulate the data in what symbol?
    11·2 answers
  • Drag the tiles to the correct boxes to complete the pairs.
    13·1 answer
  • Help, please!! A file named "games.txt" exists and has 80 lines of data. You open the file with the following line of code. aFil
    6·1 answer
  • For each of the threats and vulnerabilities from the Identifying Threats and Vulnerabilities in an IT Infrastructure lab in this
    10·1 answer
  • What does the history feature in a web browser do
    10·1 answer
  • Which printer are used to print text and graphics with high speed ​
    15·1 answer
  • In binary, the second digit from the right is multiplied by the first power of two, and the _____ digit from the right is multip
    10·2 answers
  • Vẽ sơ đồ DFD cho của hàng bán điện thoại ( Môn phân tích và thiết kế hệ thống thông tin)
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!