Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. listAppointments=[]
  2. class Appointment():
  3. def __init__(self):
  4. self._description=""
  5. self._listAppointments=[]
  6. def setDescription(self,x):
  7. self._description=x
  8. def occursOn(self,year,month,day):
  9. oa=1
  10. class Onetime(Appointment):
  11. def __init__(self,year,month,day,reason):
  12. super().__init__()
  13. self._year=year
  14. self._month=month
  15. self._day=day
  16. self._reason=reason
  17. def setDate(self):
  18. year=str(self._year)
  19. month=str(self._month)
  20. day=str(self._day)
  21. reason=str(self._reason)
  22. stringDate=str(month)+str(day)+str(year)
  23. if len(listAppointments)==0:
  24. listAppointments.append(stringDate+reason)
  25. else:
  26. found = False
  27. counter = 0
  28. while found==False and counter<len(listAppointments):
  29. if listAppointments[counter][:6]==stringDate:
  30. found=True
  31. if len(stringDate)==6:
  32. b=listAppointments[counter]
  33. b=b+reason
  34. listAppointments[counter]=b
  35. else:
  36. listAppointments.append(stringDate+reason)
  37. found=True
  38.  
  39. counter+=1
  40. class Daily():
  41. def __init__(self,year,month,day,reason):
  42. super().__init__()
  43. self._year=year
  44. self._month=month
  45. self._day=day
  46. self._reason=reason
  47. def setDate(self):
  48. year=str(self._year)
  49. month=str(self._month)
  50. day=str(self._day)
  51. reason=str(self._reason)
  52. for i in range (0,1000):
  53. dayInt=int(day)
  54. dayInt=dayInt+1
  55. day=str(dayInt)
  56. if dayInt>30:
  57. day=0
  58. month+=1
  59. if month>12:
  60. year+=1
  61. stringDay=str(month)+str(day)+str(year)
  62. if len(listAppointments) == 0:
  63. listAppointments.append(stringDate + reason)
  64. else:
  65. found = False
  66. counter = 0
  67. while found == False and counter < len(listAppointments):
  68. if listAppointments[counter][:6] == stringDate:
  69. found = True
  70. if len(stringDate) == 6:
  71. b = listAppointments[counter]
  72. b = b + reason
  73. listAppointments[counter] = b
  74. else:
  75. listAppointments.append(stringDate + reason)
  76. found = True
  77.  
  78. counter += 1
  79.  
  80. stringDate=1
  81. dentist=Onetime("19","03","19","BOBS BURGERS")
  82. dentistry=Onetime("19","03","19","DENTIST")
  83. school=Onetime("20","11","20","SCHOOL DAY")
  84. dentist.setDate()
  85. dentistry.setDate()
  86. school.setDate()
  87. school2=Daily("07","23","19","SCHHOOOOL")
  88. school2.setDate()
  89. print(listAppointments)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement