Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python. Please include comments where needed to explain code and include a scree

ID: 3828821 • Letter: P

Question

Python. Please include comments where needed to explain code and include a screenshot of output. Thank you!

The goal of this project is to give you more experience on the use of:

• classes

• inheritance

• turtle graphics

• files

• lists of lists Project

Problem 1: Employee

Write an Employee class that keeps data attributes for the following pieces of information:

• Employee name

• Employee number

Next, write two class es named ProductionWorker and ShiftSupervisor that are subclass es of the Employee class. ProductionWorker Class The P roductionWorker class should keep data attributes for the following information:

• Shift number (an integer, such as 1, 2, or 3)

• Hourly pay rate

Shift attribute will hold an integer value representing the shift that the employee w orks. The day shift is shift 1 and the night shift is shift 2.

ShiftSupervisor Class

In a particular factory, a shift supervisor is a salaried empl oyee who supervises a shift. In addition to a salary, the shift supervisor earns a yearly bo nus when his or her shift meets production goals. The ShiftSupervisor class should keep a data attribute for the :

• Annual salary

• Annual production bonus that a shift supervisor has earned.

Write the appropriate accessor and mutator methods for each class.

Once you have written the classes, write a progra m that creates two objects, object of the ProductionWorker class and an object of ShiftSupervisor r class , and prompts the user to enter data for each of the object’ s data attributes. Store the data in the object and then use the object’ s accessor methods to retrieve it and display it on the screen.

Deliverables

Turn in Project 1 .py containing all of your class and function definitions.

Explanation / Answer

class Car(object): condition = "new" def __init__(self, model, color, mpg, typeOfBattery): self.model = model self.color = color self.mpg = mpg self.typeOfBattery = typeOfBattery def displayCar(self): print "This is a %s %s with %r MPG." %(self.color,self.model,self.mpg) def driveCar(self): self.condition = "used" class ElectricCar(Car): def __init__(self, model, color, mpg, typeOfBattery): self.model = model self.color = color self.mpg = mpg self.typeOfBattery = typeOfBattery myCar = ElectricCar("prius","black",55,"molten salt") class Car(object): condition = "new" def __init__(self, model, color, mpg): self.model = model self.color = color self.mpg = mpg def displayCar(self): print "This is a " + self.color + " " + self.model + " with" + " " + str(self.mpg) + " MPG." def driveCar(self): self.condition = "used" class ElectricCar(Car): def __init__(self, model, color, mpg, typeOfBattery): self.typeOfBattery = typeOfBattery super(ElectricCar, self).__init__(model, color, mpg) def displayCar(self): super(ElectricCar,self).displayCar() print self.typeOfBattery myCar = ElectricCar("Kia", "black", 40, "molten salt") myCar.displayCar()