Question

*PYTHON* Implement a superclass Appointment and subclasses Onetime, Daily, and Monthly. An appointment has the date,...

*PYTHON* Implement a superclass Appointment and subclasses Onetime, Daily, and Monthly. An appointment has the date, the month, the year, and the description of an appointment (e.g., “see the dentist”). Then, write a method occcursOn(year, month, day) that checks whether the appointment occurs on that date.

In the test program, you should create a list of appointments using your subclasses of Onetime, Daily, and Monthly. Once you have those appointments available, allow the user to input day, month, and year to check whether the day of the month matches and print out the information of that matched appointment. For example, for a monthly appointment, you must check whether the day of the month matches. Have the user enter a date and print out all appointments that occur on that date.

Notes: you should submit two files: one class/subclass files and one test file

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program Screenshot:

from datetime import date #implementation of the class Appointment class Appointment (object): #Constructor def _init__(self,

#Implementation of the class Monthly class Monthly (Appointment): def _init__(self, day,month, year, description): super (Mon

Sample Output:

Enter the day (0 to quit): 15 Enter the month: 12 Enter the year: 2018 Do pushups Floss teeth Backup data Enter the day (0 to

Code to copy:

from datetime import date
#Implementation of the class Appointment
class Appointment(object):
   #Constructor
   def __init__(self,day,month,year,description):
       self.description=description
       self.date=date(year,month,day)
   #Defintion of the funtion __unicode__
   def __unicode__(self):
       return self.description
   #Defintion of the funtion occursOn
   def occursOn(self,day,month,year):
       if self.date == date(year,month,day):
           return True
       else:
           return False
#Implementation of the class Onetime
class Onetime(Appointment):
   def __init__(self,day,month,year,description):
       super(Onetime,self).__init__(day,month,year,description)
   #Defintion of the funtion __unicode__
   def __unicode__(self):
       return self.description
    
#Implementation of the class Daily
class Daily(Appointment):
   def __init__(self,day,month,year,description):
       super(Daily,self).__init__(day,month,year,description)
   #Defintion of the funtion __unicode__
   def __unicode__(self):
       return self.description
    
   # Defintion of the funtion occursOn
   def occursOn(self,day,month,year):
       return True
    
#Implementation of the class Monthly
class Monthly(Appointment):
   def __init__(self,day,month,year,description):
       super(Monthly,self).__init__(day,month,year,description)
   #Defintion of the funtion __unicode__
   def __unicode__(self):
       return self.description
    
   # Defintion of the funtion occursOn
   def occursOn(self,day,month,year):
       if self.date.day == day:
           return True
       else:
           return False

#create a list of appointments using your
#subclasses of Onetime, Daily, and Monthly
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"))

#Prompt and read day form the user
day = int(input("Enter the day (0 to quit): "))
while day != 0 :
   #Prompt and read month form the user
   month = int(input("Enter the month: "))
   #Prompt and read year form the user
   year = int(input("Enter the year: "))
   for app in appList :
       if app.occursOn(day,month,year) :
           print(app.description)
   #Prompt and read day form the user
   day = int(input("Enter the day (0 to quit): "))

Add a comment
Know the answer?
Add Answer to:
*PYTHON* Implement a superclass Appointment and subclasses Onetime, Daily, and Monthly. An appointment has the date,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Help me with a python program : Implement a superclass appointment and subclasses Onetime, Daily and...

    Help me with a python program : 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...

  • Programming language: JAVA Implement a superclass Appointment and subclasses OneTime, Daily, and Monthly. An appointment has...

    Programming language: JAVA 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 (int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, check whether the day of the month matches. Ask the user to enter a date to check (for example, 2006 10 5), and ask to user if they want...

  • (JAVA) In this assignment, you will implement a superclass Appointment and subclasses Onetime, Daily, and Monthly....

    (JAVA) In this assignment, you will 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(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the mon.th matches. In your application part, fill an array of Appointment objects with a mixture of appointments. Have the...

  • Write a Java program that implements a superclass Appointment and subclasses Onetime, Daily, and Monthly. An...

    Write a Java program that implements a superclass Appointment and subclasses Onetime, Daily, and Monthly. An appointment has a description (for example, “see the dentist”) and a date. It writes a method occursOn (int year, int month, int day) that checks whether the appointmentoccurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then it will fill an array of Appointment objects with a mixture of appointments. When the user...

  • 5.Implement a superclass Appointment and subclasses Onetime, Daily and Monthly. An appointment has a description (for...

    5.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 and the appointment date started before the date entered. Then, fill a list of Appointment objects with a mixture of appointments. Have the user enter a date and...

  • Create an abstract class “Appointment” that represents an event on a calendar. The “Appointment” class will...

    Create an abstract class “Appointment” that represents an event on a calendar. The “Appointment” class will have four instance variables: • An instance variable called “year” which will be of type int • An instance variable called “month” which will be of type int • An instance variable called “day” which will be of type int • An instance variable called “description” which will be of type String The “Appointment” class must also implement the following methods: • A getter...

  • Design and implement a C++ class called Date that has the following private member variables month...

    Design and implement a C++ class called Date that has the following private member variables month (int) day (nt) . year (int Add the following public member functions to the class. Default Constructor with all default parameters: The constructors should use the values of the month, day, and year arguments passed by the client program to set the month, day, and year member variables. The constructor should check if the values of the parameters are valid (that is day is...

  • The class dateType is designed to implement the date in a program, but the member function...

    The class dateType is designed to implement the date in a program, but the member function setDate and the constructor do not check whether the date is valid before storing the date in the data members. Rewrite the definitions of the function setDate and the constructor so that the values for the month, day, and the year are checked before storing the date into the data members. Add a function member, isLeapYear, to check whether a year is a leap...

  • In this exam, you will design and implement a Python class called 'Date according to the...

    In this exam, you will design and implement a Python class called 'Date according to the following API specifications. • Do NOT use any existing classes in your answer such as datetime. . You will design your class so that it operates correctly on another planet, where the total days in a year, total days in a month, and months per year may be different. For our planet Earth, you will assume that a year has 360 days and all...

  • Write a program IN PYTHON that checks the spelling of all words in a file. It...

    Write a program IN PYTHON that checks the spelling of all words in a file. It should read each word of a file and check whether it is contained in a word list. A word list available below, called words.txt. The program should print out all words that it cannot find in the word list. Requirements Your program should implement the follow functions: main() The main function should prompt the user for a path to the dictionary file and a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT