Question

You must programmatically create an office building. You will have to create 5 classes, Elevator, Programmer,...

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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
 import random class Worker(): def __init__(self, name_f, name_l, floor): self.name_f = str(name_f) self.name_l = str(name_l) self.floor = int(floor) self.energy = 1.0 def get_name(self): return self.name_f + " " + self.name_f def get_destination(self): return self.floor def get_energy(self): if (self.energy <= 0): self.energy = 0 return self.energy def __hash__(self): return hash(self.get_name()) def __eq__(self, other): if (self.get_name() == other.get_name()): return True else: return False def work(self, hours): hours = float(hours) remain = (hours * (-1/8) + 1) consume = 1 - remain self.energy = self.energy - consume class Executive(Worker): def __init__(self, name_f, name_l): self.name_f = name_f self.name_l = name_l self.floor = int(random.randrange(40, 61)) self.floor = 1.0 def work(self, hours): hours = float(hours) remain = (hours * (-1/5) + 1) consume = 1 - remain self.energy = self.energy - consume class Artist(Worker): def __init__(self, name_f, name_l): self.name_f = name_f self.name_l = name_l self.floor = int(random.randrange(20, 40)) self.energy = 1.0 def work(self, hours): hours = float(hours) remain = (hours * (-1/6.0) + 1) consume = 1.0 - remain self.energy = self.energy - consume class Programmer(Worker): def __init__(self, name_f, name_l): self.name_f = name_f self.name_l = name_l self.floor = int(random.randrange(1, 20)) self.energy = 1.0 def work(self, hours): hours = float(hours) remain = (hours * (-1/10.0) + 1) consume = 1 - remain self.energy = self.energy - consume 
Add a comment
Know the answer?
Add Answer to:
You must programmatically create an office building. You will have to create 5 classes, Elevator, Programmer,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • THIS IS WHAT I HAVE I NEED TO FIX IT SO: hours_worked should not be inputed...

    THIS IS WHAT I HAVE I NEED TO FIX IT SO: hours_worked should not be inputed separately. Get the hours as 40 40 40 40 or 40, 40, 40, 40 whichever separator suits you. How do I do this? How would you change what I have in to it getting into that kind of input. Thank you! class Employee: again = 'y' def __init__(self): self.__rate = 7.25 self.__totalhour = 0 self.__regularpay = 0 self.__overtimepay = 0 self.__totalpay = 0 self.__tax...

  • class WorkoutClass: """A workout class that can be offered at a gym. === Private Attributes ===...

    class WorkoutClass: """A workout class that can be offered at a gym. === Private Attributes === _name: The name of this WorkoutClass. _required_certificates: The certificates that an instructor must hold to teach this WorkoutClass. """ _name: str _required_certificates: List[str] def __init__(self, name: str, required_certificates: List[str]) -> None: """Initialize a new WorkoutClass called <name> and with the <required_certificates>. >>> workout_class = WorkoutClass('Kickboxing', ['Strength Training']) >>> workout_class.get_name() 'Kickboxing' """ def get_name(self) -> str: """Return the name of this WorkoutClass. >>> workout_class =...

  • YOU NEED TO MODIFY THE PROJECT INCLUDED AT THE END AND USE THE INCLUDED DRIVER TO...

    YOU NEED TO MODIFY THE PROJECT INCLUDED AT THE END AND USE THE INCLUDED DRIVER TO TEST YOUR CODE TO MAKE SURE IT WORK AS EXPECTED. Thanks USING PYTHON, complete the template below such that you will provide code to solve the following problem: Please write and/or extend the project5 attached at the end. You will have to do the following for this assignment: Create and complete the methods of the PriceException class. Create the processFile function. Modify the main...

  • DESCRIPTION You have to design an e-commerce shopping cart. These require classes Item, Electronics, Food, Dress,...

    DESCRIPTION You have to design an e-commerce shopping cart. These require classes Item, Electronics, Food, Dress, Cart and Main. ITEM CLASS Your Item class should contain: Attributes (protected) String name - name of the Item double price - price of the item Methods (public) void setName(String n) - sets the name of Item void setPrice(double p) - sets the price of Item String getName() - retrieves name double getPrice() - retrieves price String formattedOutput() returns a string containing detail of...

  • In this project, you will construct an Object-Oriented framework for a library system. The library must...

    In this project, you will construct an Object-Oriented framework for a library system. The library must have books, and it must have patrons. The patrons can check books out and check them back in. Patrons can have at most 3 books checked out at any given time, and can only check out at most one copy of a given book. Books are due to be checked back in by the fourth day after checking them out. For every 5 days...

  • In excel please show formula of how you got the answer and equation. You have the...

    In excel please show formula of how you got the answer and equation. You have the responsibility for making a report to help the company administrators to implement new employee's career plan, providing data to the investment/budget committee. So, you are managing the employee's payroll data from the new division of Data Research, created two years ago to provide the company departments (Marketing, Sales and Operations) with collection/analyze/update/report of real time market information, by making the calculation of their pay...

  • URGENT I have 3 hours for Submit this Homework so you can share yout codes with...

    URGENT I have 3 hours for Submit this Homework so you can share yout codes with me in 150mins Preliminary Notes: You have 4 hours to submit your solution. No late submission is accepted. Do not leave your submission to the last minute. You are not allowed to copy any code from anywhere. Your code will be checked by a software for similarity. Implement the code on your own and never share it with someone else. A test code is...

  • SESSION 12 Workers for Ivanka's clothing company The reality of working in a factory making clothes...

    SESSION 12 Workers for Ivanka's clothing company The reality of working in a factory making clothes for Ivanka Trump’s label has been laid bare, with employees speaking of being paid so little they cannot live with their children, anti-union intimidation and women being offered a bonus if they don’t take time off while menstruating. The Guardian has spoken to more than a dozen workers at the fashion label’s factory in Subang, Indonesia, where employees describe being paid one of the...

  • Subject: HRM Introduction and Instructions You have recently been hired as the Director of Human Resources...

    Subject: HRM Introduction and Instructions You have recently been hired as the Director of Human Resources for Wilson Brothers Canada and have HR responsibility for all of the company’s Canadian operations. Bob and John Wilson have asked you to prepare a report for their review focusing specifically on organizational behavior within the company. Review the Wilson Brothers Case Scenario in depth and address the required topic listed below in your analysis report. Marks are allocated for thoroughness of coverage of...

  • Help with Data Science python notebook, Question 1 Create a function called vowel_parse() that takes a...

    Help with Data Science python notebook, Question 1 Create a function called vowel_parse() that takes a single string as input. This string is the name of the input directory. It returns a dictionary. This dictionary has keys that are the names of the individual input files. The dictionary values are the number of words in that file that have adjacent vowels ('aa', 'ae', 'oo', 'ia', etc.). Use a regular expression to find these, do not hard code every possible combination...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT