You are building a program to model different types of animals. You have been given the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You are building a program to model different types of animals. You have been given the following abstract class for the Animal Time left 1:34:25 class: public abstract class Animal { private String name; private int age; public Animal(String name, int age) ( 1 this.name name; this.age age; } public String getName() { return name; } public int getAge() ( return age; } public abstract String getSound(); Create two classes that extend the Animal class: Cat and Dog. The Cat class should have an additional instance variable numLives, and a constructor that takes name, age, and numLives as parameters. The Cat class should also override the getsound() method to return "Meow". The Dog class should have an additional instance variable breed, and a constructor that takes name, age, and breed as parameters. The Dog class should also override the getSound() method to return "Woof". Write the code for the Cat and Dog classes, implementing the Animal abstract class with the additional methods specified above. The constructors in the subclasses must use super and call the superclass constructor. You are building a program to model different types of animals. You have been given the following abstract class for the Animal Time left 1:34:25 class: public abstract class Animal { private String name; private int age; public Animal(String name, int age) ( 1 this.name name; this.age age; } public String getName() { return name; } public int getAge() ( return age; } public abstract String getSound(); Create two classes that extend the Animal class: Cat and Dog. The Cat class should have an additional instance variable numLives, and a constructor that takes name, age, and numLives as parameters. The Cat class should also override the getsound() method to return "Meow". The Dog class should have an additional instance variable breed, and a constructor that takes name, age, and breed as parameters. The Dog class should also override the getSound() method to return "Woof". Write the code for the Cat and Dog classes, implementing the Animal abstract class with the additional methods specified above. The constructors in the subclasses must use super and call the superclass constructor.
Expert Answer:
Answer rating: 100% (QA)
The task involves creating two subclasses of the abstract class Animal Cat and Dog Lets write the co... View the full answer
Related Book For
Financial Accounting Tools for Business Decision Making
ISBN: 978-1118024492
5th Canadian edition
Authors: Paul D. Kimmel, Jerry J. Weygandt, Donald E. Kieso, Barbara Trenholm, Wayne Irvine
Posted Date:
Students also viewed these programming questions
-
Describe three ways in which a gradual increase in an extracellular signal can be sharpened by the target cell to produce an abrupt or nearly all-or none response.
-
Sofa Company manufactures two models of its couch, the Mini and the Maxi. The Mini model requires 10,000 direct labor hours and the Maxi model requires 40,000 direct labor hours. The company produces...
-
On January 1, 2019, Parkway Company adopted a defined benefit pension plan. At that time, Parkway awarded retroactive benefits to its employees, resulting in a prior service cost of $2,180,000 on...
-
What controls should be observed in witnessing the distribution of a payroll?
-
These financial statement items are for Major Company at year-end, July 31, 2012. Instructions (a) Prepare an income statement and an owner?s equity statement for the year. The owner did not make any...
-
Ahmed Khan has been given the choice by his employer Amber Ltd to select as from 1 March 2017 either the free use of a company car for private and business purposes or a travelling allowance. Ahmed...
-
WW Development Inc. (WW), a real estate developer, was incorporated in Canada in 1975 by two brothers, Peter and David Wang. In the 1980s and 1990s, WW was quite successful. In early 2002, Peter and...
-
Weber Company purchased a mining site for $689,092 on July 1. The company expects to mine ore for the next 10 years and anticipates that a total of 82,882 tons will be recovered. The estimated...
-
You are the new HR Manager for Company X, reporting to the General Manager (GM) of the company. When you examined the current Compensation & Benefits (C&B) structure of your new company, you found...
-
Pinter Company employs the voucher system in controlling expenditures and disbursements. All cash receipts are deposited each Wednesday and Friday in a night, depository after banking hours. The data...
-
n i=1 - - let denote the sample correlation coefficient between Y and X (defined formally below), and let = 1 (yi ) and = - 1(xi). (These notations are also defined in slides 44-46 of Chapter 1...
-
Consider x = (X1, X2,..., X)~N(, ), where = (1, 2, ..., Hp) and (ij), that is ij is the ijth element of the pp variance- covariance matrix (6 points, 2 points each) a. Show that X; ~N(, o) for any...
-
a. Use the following information to create the 2017 and 2018 income statements. b. Create the 2017 and 2018 balance sheets. c. Then create the 2018 indirect cash flow statement. Accounts payable...
-
Given a string, divide it into two substrings such that the substrings have the most possible characters in common. The cut commonality is number of characters in common between the two substrings....
-
Respond to the ethical judgments required based on the following scenarios. Scenario 1. Assume you have collected a sample using MUS and that you have evaluated that sample to calculate a total...
-
From the information in BE5-6, prepare the journal entries to record the sales transactions on Feng Corp.'s books, assuming a periodic inventory system is used instead of a perpetual inventory...
-
A friend of your family, Nancy Chen, has just graduated from dental school and is opening up her new practice. To do this, she has formed a corporation called Chen Dental Services Ltd. Revenues from...
-
The bookkeeper for Cater's Dance Studio Ltd. did the following in journalizing and posting: 1. A debit posting to the Interest Revenue account of $600 was omitted. 2. A credit of $500 for revenue...
-
The following are methods used to evaluate public health data and scientifc evidence except a. Use of standard criteria by experts b. By combining the results of multiple scientifc studies that are...
-
Which industrial transducer does not require a power supply (selfgenerated signal)?
-
Nordson Co. of Amherst, Ohio, a maker of painting and glue equipment, exports nearly half its output. Customers value its reliability as a supplier. Because of an especially sharp run up in the value...
Study smarter with the SolutionInn App