Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 forProgrammer, 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. defwork(hours): Anexecutiveonly 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 workerclass's functionsbecause 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 defwork(hours:float): Anartist 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 workclass's functionsbecause 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 defwork(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.

Elevator

An elevator is an object that is able to hold workers and transport them to a destination. The elevator's destination is a specific floor (int). This destination of the elevator my change depending on its occupants and the minimum and maximum floor that is services. def __init__(capacity:int, min_floor:int, max_floor:int):

This is the constructor of the elevator the capacity is the maximum amount of occupants that this elevator my hold. min_floor is the lowest floor that the elevator may go to and the max_floor - 1 is the highest floor that the elevator may travel to, both values will be greater than 0.min_floor bool: This method adds a worker to the elevator. If the elevator is already full (meaning the total number of workers on the elevator currently is >= the capacity specified at initialization) then the worker should not be added to the elevator. Returns True if the person was added to the elevator and false if they were not added. def services_floor(floor:int)-> bool: This should return True if the floor specified as a parameter is >= min_floor specified at initialization of this object and < max_floor specified at initialization of this object. def riders() -> set: This should return a set containing all of the workers on the elevator. def max_riders() -> int: This will return thecapacity specified atinitialization. def full() -> bool: This will return True if the total number of workers on this elevator is >= the capacity specified when this object was created. def current_floor() -> int: A number indicating which floor this elevator is currently on, this should never be less than 0. See move() to understand how this elevator may move from one floor to the next. defdirection() -> int: This function will return a number greater than or less than zero. The value return will tell you which direction the elevator is going to move the next time move() is called. This will decide the direction by choosing the closest worker's destination to the elevator's current floor. def move() -> set: This function will move the elevator up or down one floor. The direction that the elevator will move is based on the value returned by direction(). Please see the direction() documentation for a better understanding. This function will return a set of workers on the elevator whose destination is equal to the floor that the elevator has moved to. Once this method is called and it has returned a set of workers that have gotten off the elevator those workers that have left the elevator should not be in the set of workers returned by riders().

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

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions

Question

Identify the elements that make up the employee reward package.

Answered: 1 week ago

Question

Understand the purpose, value and drawbacks of the interview.

Answered: 1 week ago