I need this in PYTHON please. Thank you! Implement a superclass Appointment and
ID: 3696007 • Letter: I
Question
I need this in PYTHON please. Thank you!
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 date.txt for your input file (change the data to run different tests) and demo-appointment.py for your program that calls your class Appointment.
This is a pic of the date.txt
Explanation / Answer
#Appointment Class
import os
import re
#parent class
class Appointment():
def __init__(self,*args):
print (" --- initilaize ---");
#parents class method
def occursOn(self,year,month,day):
print('---year --',year);
#years data appended using list
years_data=[];
#day data appended using list
day_data=[];
app_year = year;
app_day = day;
#if year exist then it will append to list
if app_year:
years_data.append(app_year)
#if day exist then it will append to list
if app_day:
day_data.append(app_day);
#iterate list
for eachyear in years_data:
print(eachyear);
#child class inherits from Appointment class
class demoAppointment(Appointment):
def __init__(self,*args):
print ('---from demo appointment init ---');
def demoOccursOn(self,*args):
#parents class demoOccurs method call
super().occursOn(year,month,day);
demo = demoAppointment();
year = input("Enter date ");
month = input("Enter month");
day = input("Enter year");
#demo.occursOn(year,month,day);
demo.demoOccursOn();
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.