Question
from datetime import date class Appointment(object): def __init__(self,day,month,year,description): self.description=description self.date=date(year,month,day) def __unicode__(self): return self.description def occursOn(self,day,month,year): if self.date == date(year,month,day): return True else: return False
from datetime import date
class Appointment(object): def __init__(self,day,month,year,description): self.description=description self.date=date(year,month,day) def __unicode__(self): return self.description def occursOn(self,day,month,year): if self.date == date(year,month,day): return True else: return False class Onetime(Appointment): def __init__(self,day,month,year,description): super(Onetime,self).__init__(day,month,year,description) def __unicode__(self): return self.description class Daily(Appointment): def __init__(self,day,month,year,description): super(Daily,self).__init__(day,month,year,description) def __unicode__(self): return self.description #function over written def occursOn(self,day,month,year): return True # because daily appointment is true for all days class Monthly(Appointment): def __init__(self,day,month,year,description): super(Monthly,self).__init__(day,month,year,description) def __unicode__(self): return self.description #function over written def occursOn(self,day,month,year): if self.date.day == day: return True else: return False
appList = [] appList.append(Daily(1, 1, 2013, "Do pushups")) appList.append(Daily(15, 1, 2013, "Floss teeth")) appList.append(Monthly(15, 12, 2012, "Backup data")) appList.append(Onetime(21, 12, 2012, "Computer Science Final Exam")) appList.append(Monthly(4, 2, 2013, "Call grandma")) appList.append(Onetime(12, 4, 2013, "See dentist"))
day = int(input("Enter the day (0 to quit): ")) while day != 0 : month = int(input("Enter the month: ")) year = int(input("Enter the year: ")) for app in appList : if app.occursOn(day,month,year) : print(app.description) day = int(input("Enter the day (0 to quit): "))
In the above program, Improve the appointment book program of the previous exercise. Give the user the option to add new appointments. The user must specify the type of appointment, the description and date
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started