Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Bob is a Contactor and Computer Scientist who does work on trailers. To track his work he wrote a program that tracked: how much money

Bob is a Contactor and Computer Scientist who does work on trailers. To track his work he wrote a program that tracked: how much money he made and how many trailers he'd worked on.
This program has the capacity to be very useful for any job involving homes: mansions, bungalows, condos, etc. To make this program more marketable to a wider audience it needs to be refactored into a generic program using abstract classes. By making a job class other than Contractor and another home-type class the program will become valuable to many more people. Your task is to:
Write the abstract class, abstractHouse, which has:
an integer variable for the number of rooms in the house
a double variable for the value of the house
an integer variable for the amount of work required on the house
an integer variable to act as a work counter, tracking the amount of work done on the house
an abstract void method to calculate the value of the house
an abstract Boolean method to perform work
Write the Mansion class implementing the abstractHouse class. You may refer to the Trailer class for hints on implementation. The Mansion class must have:
an integer variable for the number of floors
a Boolean variable indicating if it has a driveway, if it has one increase the house value by 200 and work required of the house by 20
a Boolean variable indicating if it is furnished, if it is increase the value by 500 and work required by 100
implemented abstract methods
a constructor that takes as input the number of rooms, the number of floors, a Boolean value hasDriveway and a Boolean value isFurnished.
Write a class for a job that involves working with houses other than the Contractor. You may refer to the Contractor class for implementation ideas. This class must:
maintain a Queue of houses that are either being currently worked on, or will be worked on
call the implemented abstract methods in the queue
a double variable, wallet, initially at 0 that tracks the amount of money earned from completing house jobs
an integer counter, tracking the number of houses completed
when complete all jobs, summarize the number of jobs completed and amount earned
randomly add new jobs of a random house type, be careful with this as you could enter an infinite loop. Refer to the numbers used in Contractor for an approach.
Exceed the Expectations: Does the doWork() method need to be abstract? Try to refactor the program so that doWork() is not abstract but may call an abstract method

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

Students also viewed these Databases questions

Question

Describe ERP and how it can create efficiency within a business

Answered: 1 week ago