IN PYTHON PLEASE! I am supposed to be inputing a file called data.txt-- thanks f
ID: 3828112 • Letter: I
Question
IN PYTHON PLEASE!
I am supposed to be inputing a file called data.txt-- thanks for the help!
Implement a superclass Appointment and subclasses Onetime, Daily and Monthly. An appointment has a description (for example, “see the dentist”) and a date. Write a method occursOn(year,month,day) that checks whether the appointment occurs on that date. For example for a monthly appointment, you must check whether the day of the month matches. Then, fill a list of Appointment objects with a mixture of appointments. Have the user enter a date and print out all appointments that occur on that date.
Download data.txt for your input file (change the data to run different tests) and demo-appointment.py for your program that calls your class Appointment.
Test Cases:
Add 2 appointments:
Day Month Year Descr O,D,M
13 6 2017 Jog D
15 1 2016 Haircut M
List
Day Month Year
15 2 2012
4 4 2013
Explanation / Answer
# Hello World program in Python
from datetime import date
class Appointment:
desc=""
date=""
def __init__(self, desc, year, month, day):
self.desc=desc;
today=date.today()
def occursOn(year, month, day):
today=date.today()
today.year
today.month
today.day
checkDate=today.parse(today.year,today.month,today.day)
return checkDate.equals(self.date)
def print(self):
print "Appointment :",self.desc, today.year, today.month, today.day
class OneTime(Appointment):
def occursOn(year, month, day):
today=date.year
checkDate=today.parse(today.year)
return checkDate.equals(self.year)
class Daily(Appointment):
def occursOn(year, month, day):
today=date.day
checkDate=today.parse(today.day)
return checkDate.equals(self.day)
class Monthly(Appointment):
def occursOn(year, month, day):
today=date.month
checkDate=today.parse(today.month)
return checkDate.equals(self.month)
file=open("data.txt","w")
file.write("Run different tests")
file.close()
d=Daily()
List.add(d.year, d.month, d.day)
return List