Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do Question C plz B: Programming [10 marks Write a concrete Java class called Cat that extends the provided Animal class. A cat has an

image text in transcribed
image text in transcribed
Do Question C plz
B: Programming [10 marks Write a concrete Java class called Cat that extends the provided Animal class. A cat has an additional attribute that keeps track of how many lives it has left (an integer). Your Cat class must have a constructor that take its name, age and number of lives left as input (setting its initial state appropriately). Your Cat class must have a second that takes only the name and age and automatically sets the number of lives left to 9. This constructor must use constructor chaining. A cat's noise consists of "meow" repeated as many times as it has lives left. Your class must use encapsulation. You should have an appropriate getter for the lives left 1 public abstract class Animalf 2 protected String name; a protected int age 4 public Animal(String name, int age)t this.name name; this.age -age public String getName retur this.nane; h s public abstract String noise C: Programming [10 marks This problem uses the classes from the previous problem (Animal and Cat). Write a Java program that uses one command line argument (that w always be an integer; you do not need to check this in your c Using the Helper class below, your program will call makeAnimals) to generate an array of size N (where N is the value specified by the command line argument). Your program then print out the name of the animal in the returned list with the loudest noise (longest string). If the animal with the loudest noise is a cat then your program will also print out the number of lives that this cat has left. You can assume that no two animal objects have the same noise level (length of string) public class Helper public tatic Animal [] makeAnimals (int n)( ) /Returns an array of n randomly created animals 4 The animals could be cats, dogs or bats s I/ (each of which extends the Animal class)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions