Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. Enter a class called Shift in the Shift.py file that represents a supermarket employee's shift. This class has a single field called Clock type duration, which represents the duration of the shift.
  2.  
  3. Implement a constructor that receives two start and finish parameters of the Clock type that represent the start time and the end time, respectively.
  4.  
  5. The constructor needs to update the duration length of the shift.
  6. Set the default value of the finish parameter to None. If the constructor is initialized with a single parameter, the start parameter represents the length of the shift, so the duration field should be updated accordingly (see example below).
  7. def __init __ (self, start, finish = None)
  8.  
  9. • Shift object printing must be supported. Printing a Shift object will print the shift duration in the following format: HH: MM. For example, for the rows:
  10. s1 = Shift.Shift (Clock.Clock (6, 20), Clock.Clock (16, 0)) # start: 06:20, finish: 16:00.
  11. s2 = Shift.Shift (Clock.Clock (8, 43)) # shift duration: 08:43 (here, finish equal to None).
  12. print (s1)
  13. print (s2)
  14.  
  15. You will receive the following printout:
  16. 09:40
  17. 08:43
  18. • Shift connection operation must be supported. Note that the original objects with which you make the connection should not be changed. The result of the connection represents the length of the shifts together (the length of the shift after the agreement may be 24 hours). Sample for the lines:
  19. s_1 = Shift.Shift (Clock.Clock (6, 20), Clock.Clock (16, 0))
  20. s_2 = Shift.Shift (Clock.Clock (14, 0), Clock.Clock (20, 30))
  21. s_3 = Shift.Shift (Clock.Clock (0, 0), Clock.Clock (9, 10))
  22. print (s_1 + s_2 + s_3)
  23. You will receive the following printout:
  24. 25:20
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement