Question
You must programmatically create an office building. You will have to create 5 classes, Elevator, Programmer, Artist, Executive, and Worker. All the classes will work
You must programmatically create an office building. You will have to create 5 classes, Elevator, Programmer, Artist, Executive, and Worker. All the classes will work with each other. Please use any python data structures (List, Sets, and Dictionaries) and what we have learned about object-oriented programming to develop this program. You will find documentation for the functions that you must implement for each class below. Feel free to use the accompanying unit test to test your code. Feel free to use Grader Than to submit your work to receive your Grade instantly and help. You may submit your work via Moodle or Grader Than.
Worker
This is a base class for Programmer, Artist, and Executive. The worker has a first name (str) and last name (str) a destination floor (int) and a total amount of energy (float 0-1).
def __init__(first_name:str, last_name:str, destination:int): The constructor for the class. first_name is a string representing the first name of the worker. last_name is a string representing the last name of the worker. the destination is an integer representing the floor the workers are going to get off on.
def get_destination() ->int:
Should return destination specified when the worker was constructed.
def get_name() -> str:
should return the first and last name separated by a space.
def __hash__()->int:
This should hash the string returned by get_name(). def __eq__(other)->bool:
This should test if one object of type Worker is equal to another type. Hint, testing if their names are equal will suffice.
def work(hours:float):
A worker only has enough energy to work 8 hours a day. This should decrease the worker's energy by a quantity that will make their energy level 0 when they have worked 8 hours. Or make their energy equal to .5 when they have worked 4 hours.
def get_energy() ->float :
Returns the current amount of energy the worker has within a 0-1 range. This should change after work() is called with a given amount of hours. This should never return less than 0.
Executive
This class extends workers but overrides worker class's functions because executives only work 5 hours a day. Executives' destination floor is a random floor between 40 and 60.
def __init__(first_name:str, last_name:str): Their floor should be randomly selected between 40 and 60.
def work(hours):
An executive only has enough energy to work 5 hours a day. This should decrease the worker's energy by a quantity that will make their energy level 0 when they have worked 5 hours.
Artist
This class extends workers but overrides worker class's functions because artists only work 6 hours a day. Artist's destination floor is a random floor between 20 and 39.
def __init__(first_name:str, last_name:str): Their floor should be randomly selected between 20 and 39
def work(hours:float):
An artist only has enough energy to work 6hours a day. This should decrease the worker's energy by a quantity that will make their energy level 0 when they have worked 6 hours.
Programmer
This class extends workers but overrides work class's functions because programmers work 10 hours a day. The programmer's destination floor is a random floor between 1 and 19.
def __init__(first_name:str, last_name:str): Their floor should be randomly selected between 1 and 19
def work(hours:float):
A programmer only has enough energy to work 10 hours a day. This should decrease the worker's energy by a quantity that will make their energy level 0 when they have worked 10 hours.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started