IT 117: Intermediate Scripting
Homework 11


Due Sunday, December 3rd at 11:59 PM

Deliverables

There is one deliverable for this assignment: It must be in an hw11 directory, which you must create inside a hw directory inside you it117 directory.

Make sure the script obeys all the rules in the Script Requirements page.

Specification

Your hw11.py script should contain the two classes below as well as the test code.

Employee Class

Create the class Employee with two hidden attributes
This class will only have a constructor, an __str__ method and getters for the two attributes.

The constructor must have the following header
	def __init__(self, name, number):

ProductionWorker Class

Create the class ProductionWorker which is a subclass of Employee.

This constructor must have the same header as the one for Employee.

The constructor must call the Employee.

The constructor must also set two hidden attributes to their default values.
The class must have the following accessor methods
The class must have an __str__ method which returns a string containing all the attributes.

The class must also have the mutator set_shift which will only accept integers of 1, 2 and 3, and will print an error message if given a value that cannot be turned into an integer or a value other than the ones given above and leave the original value in place.

The class must have the mutator set_rate which will only accept a float value in the range 15.00 to 50, and will print an error message if given a value that cannot be turned into an integer or a value outside the range and leave the original value in place.

Suggestions

Testing

Your output should look something like this

	Be sure to run this script on the Unix machine so you know it works 
	in the environment in which I will run it when I score your homework.
	

Your script must contain the following test code
if __name__ == '__main__':    
    e1 = Employee("Frank", 1)
    print(e1.get_name(), e1.get_number())
    print(e1)
    print()
    e2 = ProductionWorker('Sam', 2)
    print(e2.get_name(), e2.get_number(), e2.get_shift(), e2.get_rate())
    e2.set_shift('one')
    print('shift:', e2.get_shift())
    e2.set_shift(4)
    print('shift:', e2.get_shift())
    e2.set_shift(2)
    print('shift:', e2.get_shift())
    e2.set_rate('twenty')
    print('rate:', e2.get_rate())
    e2.set_rate(10)
    print('rate:', e2.get_rate())
    e2.set_rate(20)
    print('rate:', e2.get_rate())
    print(e2)
Your output should look something like this
$ ./hw07.py 
Frank 1

Sam 2 1 15.0
one cannot be converted into an integer
shift: 1
shift can only be 1, 2 or 3
shift: 1
shift: 2
twenty cannot be converted into a float
rate: 15.0
rate must be between 15.00 and 50.00
rate: 15.0
rate: 20.0
Sam, 2, shift: 2, rate: $20.0