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]
3 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]3 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
A user purchased a new smart home device with embedded software and connected the device to a home network. The user then regist
Rzqust [24]

Answer:

C. The user is sent an e-mail appearing to be from the manufacturer, asking the user to confirm account password by clicking on a link in the e-mail and entering password on the resulting page.

Explanation:

Phishing attack is a cyber atttack in which user is sent an email which he thinks is useful. When the user open the email and does as instructed in the email his account gets locked. His personal information is haccked and then rannsom is demanded to release that information. The hacckers usually steal credit card information and bank details of the user which are misused.

7 0
3 years ago
(1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Outpu
Alexeev081 [22]
No one is going to do this
4 0
3 years ago
Groupthink refers toA) the willingness of individual group members to withhold contrary or unpopular opinions, even when those o
Ivan

Answer:

The correct answer is A.

Explanation:

Groupthink is a theory that is applied to decision making psychology in groups, developed by Irving Janis. The theory roots itself to the problem of conformity especially in group settings. When a decision is made in a group, some members, even though they believe that the decision made is wrong or can be better, get caught up in the conformity problem and follow the accepted solution to allign with the group's decision.

I hope this answer helps.

5 0
3 years ago
Write a recursive, string-valued method, reverse, that accepts a string and returns a new string consisting of the original stri
Ket [755]

The program is an illustration of recursive functions in Python;

Recursive functions are functions executed from within itself

<h3>The python program</h3>

The program written in python, where comments are used to explain each action is as follows:

#This defines the function

def revStr(myStr):

   #This returns an empty string if the string is empty

   if myStr == "":

       return myStr

   #If otherwise, this returns the reversed string recursively

   else:

       return revStr(myStr[1:]) + myStr[0]

Read more about python recursions at:

brainly.com/question/19089783

#SPJ1

8 0
2 years ago
What is microsoft certification?
BabaBlast [244]
Microsoft certification is a series of programs that provide certification of competence in Microsoft products.
6 0
3 years ago
Other questions:
  • Physical parts of components of a computer system is called
    9·1 answer
  • for which is a chart legend used? a.all of the time b.whenever you are comparing data that is the same c.whenever you are compar
    9·2 answers
  • Discuss and compare shared and switch Ethernet
    12·1 answer
  • Write a C++ program that reads from the standard input and counts the number of times each word is seen. A word is a number of n
    9·1 answer
  • The marketplace for computer hardware:________ 1. has become increasingly concentrated in top firms 2. has expanded to include a
    5·2 answers
  • A program uses two classes: dog and poodle. which class is the base class and which is the derived class?
    7·2 answers
  • What section of the outline is represented by "A. Africa?"
    11·2 answers
  • Which of these is not a valid form<br>layout in Microsoft Access?​
    11·1 answer
  • Question #2
    11·1 answer
  • 4. When working at the CLI in Linux, you specify the exact location of a file, which is the ____________________ to it, by begin
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!