Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Week 15
- #1)
- '''
- Write a class named RetailItem that holds data about an item in a retail store. The class should store the following data in attributes: item description,
- units in inventory, and price. Once you have written the class, write a program that creates three RetailItem objects and keeps them stored in a list. The
- RetailItem objects should store the following data in them:
- Description Units_in_Inventory Price
- Item #1 Jacket 12 59.95
- Item #2 Designer Jeans 40 34.95
- Item #3 Shirt 20 24.95
- Item #4 Socks 34 14.55
- Item #5 Tuxedo 7 184.22
- Item #6 Dress 17 42.85
- Next create a CashRegister class that can be used with the RetailItem class. The CashRegister class should be able to internally keep a list of RetailItem objects.
- The class should have the following methods:
- - A method named scan_item that accepts a RetailItem object as an argument. Each time the purchase_item method is called, the RetailItem object that is passed
- as an argument should be added to the internal list.
- - A method named get_total that returns the total price of all the RetailItem objects currently stored in the CashRegister object’s internal list.
- - A method named show_items that neatly displays data about all the current RetailItem objects stored in the CashRegister object’s internal list.
- - A method named purchase that should first call show_items, then display the result from get_total. It should then clear the CashRegister object’s internal list
- by removing the object and decreasing the Units_in_Inventory by 1.
- Demonstrate the CashRegister class in a program that allows the user to repeadadly select several items for purchase. When the user is ready to check
- out, the program should call purchase in order to display a list of all the items he or she has selected for purchase, the total price, and correctly update
- the inventory of the items.
- '''
- #2)
- '''
- Write an Employee class that keeps data attributes for the following pieces of information:
- Employee name
- Employee ID number
- Hourly Pay
- Hours Worked
- And a method called pay_day that returns the hourly pay * hours worked and sets hours worked back to zero
- Next, write a class named ShiftWorker that is a subclass of the Employee class. The ShiftWorker class should keep data attributes for the
- following information:
- Shift number (an integer, such as 1, 2, or 3)
- Vacation Hours
- Sick Hours
- An updated method pay_day that uses its inherited one and also adds (vacation hours + sick hours) * hourly pay before returning
- Next, write a class named ShiftSupervisor that is a subclass of the ShiftWorker class. The ShiftSupervisor class should keep data attributes for the
- following information:
- Bonus
- An updated method pay_day that uses its inherited one and also adds the bonus before returning
- Demonstrate these class by writing a program that creates an Employee, a ShiftWorker, and a ShiftSupervisor. Show them working correctly by calling each of
- their pay_day functions and printing the result next to the expected result for example, the result for an Employee with 40 hours worked and an hourly pay
- of 15 should look like this:
- Expected payday : 600.00
- Running payday function . . .
- #Run payday function now, then print result
- Returned payday : 600.00
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement