Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. #Week 15
  2. #1)
  3. '''
  4. 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,
  5. 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
  6. RetailItem objects should store the following data in them:
  7.  
  8. Description Units_in_Inventory Price
  9. Item #1 Jacket 12 59.95
  10. Item #2 Designer Jeans 40 34.95
  11. Item #3 Shirt 20 24.95
  12. Item #4 Socks 34 14.55
  13. Item #5 Tuxedo 7 184.22
  14. Item #6 Dress 17 42.85
  15.  
  16.  
  17. 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.
  18. The class should have the following methods:
  19.  
  20. - 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
  21. as an argument should be added to the internal list.
  22.  
  23. - A method named get_total that returns the total price of all the RetailItem objects currently stored in the CashRegister object’s internal list.
  24.  
  25. - A method named show_items that neatly displays data about all the current RetailItem objects stored in the CashRegister object’s internal list.
  26.  
  27. - 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
  28. by removing the object and decreasing the Units_in_Inventory by 1.
  29.  
  30. 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
  31. 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
  32. the inventory of the items.
  33. '''
  34.  
  35.  
  36. #2)
  37. '''
  38. Write an Employee class that keeps data attributes for the following pieces of information:
  39. Employee name
  40. Employee ID number
  41. Hourly Pay
  42. Hours Worked
  43. And a method called pay_day that returns the hourly pay * hours worked and sets hours worked back to zero
  44.  
  45. Next, write a class named ShiftWorker that is a subclass of the Employee class. The ShiftWorker class should keep data attributes for the
  46. following information:
  47. Shift number (an integer, such as 1, 2, or 3)
  48. Vacation Hours
  49. Sick Hours
  50. An updated method pay_day that uses its inherited one and also adds (vacation hours + sick hours) * hourly pay before returning
  51.  
  52. Next, write a class named ShiftSupervisor that is a subclass of the ShiftWorker class. The ShiftSupervisor class should keep data attributes for the
  53. following information:
  54. Bonus
  55. An updated method pay_day that uses its inherited one and also adds the bonus before returning
  56.  
  57.  
  58. Demonstrate these class by writing a program that creates an Employee, a ShiftWorker, and a ShiftSupervisor. Show them working correctly by calling each of
  59. 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
  60. of 15 should look like this:
  61.  
  62. Expected payday : 600.00
  63. Running payday function . . .
  64. #Run payday function now, then print result
  65. Returned payday : 600.00
  66.  
  67.  
  68. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement