Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a) Write the definition of a classPersonthat contains anamefield oftype String and anagefeld of type int. Then define two classes,DancerandDonutMaker,that extendPersonsuch thatDancerhas an additionalfield calledcompanyof

a) Write the definition of a classPersonthat contains anamefield oftype String and anagefeld of type int. Then define two classes,DancerandDonutMaker,that extendPersonsuch thatDancerhas an additionalfield calledcompanyof type String, andDonutMakerhas an additionalfield calledshopof type String.

b)Define a classCountingthat contains a methodDancersAges(Person[a]), such that DancersAgesreturns the sum of the agefields of the Dancerobjectsreferenced by the array a. There is no need for an object of classCounting to becreated in order forDancersAgesto be called.

c)Define a classMainClasscontaining themainmethod (for the entireprogram).The mainshould create an array with 10 elements, namely 5Dancerobjects and 5 DonutMakerobjects in alternating order, and passthe array to theDancersAgesmethod, above. You can initialize the fieldsof the objects as you see fit.

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

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

Identify and discuss learning style differences across cultures

Answered: 1 week ago

Question

3. You can gain power by making others feel important.

Answered: 1 week ago