Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in python that handles an appointment calendar. The user can ent

ID: 3865660 • Letter: W

Question

Write a program in python that handles an appointment calendar. The user can enter an appointment with a month, day, and event, and the appointment can be one-time, daily, or monthly. The user can also list all the appointments for a particular month and day.

Create a file called appointment.py, which contains an abstract superclass named Appointment and 3 subclasses named: Onetime, Daily, Monthly.

The abstract Appointment class constructor requires a month, day, and event argument. This superclass requires all subclasses to have an occursOn method.

The 3 subclasses all have a __repr__ method to print the object's type of appointment, the date and event (see sample output).

The 3 subclasses all have an occursOn method, which accepts a month and day input, and returns True / False depending on whether the current appointment object will occur on the input month / day.

Create a file called apptManager.py, which contains an ApptManager class. This class has the following methods:

A public processChoice method that will:

print a menu to add, list, or quit

read in the user choice

process the user's menu choice

Keep looping to ask for a choice if the choice is not valid (see sample output).

A private getDate method that asks for a month and day. Keep looping to ask for input until there is a valid month and day (see sample output).

A private addAppointment method that will:

call the getDate method to get the appointment date

ask for the event name and the type of event (one-time, daily, monthly). Keep looping if the user doesn't enter the correct type (see sample output).

create the correct type of appointment object and store it

A private listAppointment method that:

prints a "no appointment" if there nothing has been scheduled

call getDate to get a month / day

print all appointments that will occur on that month / day

Sample output on next page

a. add, l. list, q. quit.

Your choice? n                            # invalid choice, keep looping

choice a, l, q only

a. add, l. list, q. quit.

Your choice? 3                            # invalid choice, keep looping

choice a, l, q only

a. add, l. list, q. quit.

Your choice? l                            # no appointment scheduled

There is no appointment scheduled

a. add, l. list, q. quit.

Your choice? a                            # add daily appointment

New appointment

Month: 7

Day: three                                # invalid day, keep looping

day and month must be integers

Month: 7

Day: 3

Name: CIS41A class

o. onetime, d. daily, or m. monthly? d

a. add, l. list, q. quit.

Your choice? a                            # add one time appointment

New appointment

Month: 7

Day: 4

Name: Fireworks

o. onetime, d. daily, or m. monthly? o

a. add, l. list, q. quit.

Your choice? a                            # add one time appointment

New appointment

Month: 7

Day: 24

Name: Midterm

o. onetime, d. daily, or m. monthly? o

a. add, l. list, q. quit.

Your choice? a                            # add monthly appointment

New appointment

Month: 6

Day: 10

Name: Library

o. onetime, d. daily, or m. monthly? m

a. add, l. list, q. quit.

Your choice? a                            # add daily appointment

New appointment

Month: 8

Day: 7

Name: Study

o. onetime, d. daily, or m. monthly? d

a. add, l. list, q. quit.

Your choice? l                            # list all appts for one day

List appointment(s) for

Month: 7

Day: 24

Daily appointment starting (07/03): CIS41A class

One time appointment (07/24): Midterm

a. add, l. list, q. quit.

Your choice? l                                  # list appts for one day

List appointment(s) for

Month: August                                   # invalid month, keep looping

day and month must be integers

Month: 8

Day: 10

Daily appointment starting (07/03): CIS41A class

Monthly appointment starting (06/10): Library

Daily appointment starting (08/07): Study

a. add, l. list, q. quit.

Your choice? a                                  # add one time appointment

New appointment

Month: 8

Day: 10

Name: Final

o. onetime, d. daily, or m. monthly? o

a. add, l. list, q. quit.

Your choice? l                                  # same list, with newly added appt

List appointment(s) for

Month: 8

Day: 10

Daily appointment starting (07/03): CIS41A class

Monthly appointment starting (06/10): Library

Daily appointment starting (08/07): Study

One time appointment (08/10): Final

a. add, l. list, q. quit.

Your choice? q

Explanation / Answer

import calendar #Create a plain text calendar c= calendar.TextCalendar(calendar.THURSDAY) str= c.formatmonth(2015,1,0,0) print str #Create an HTML formatted calendar hc = calendar.HTMLCalendar(calendar.THURSDAY) str = hc.formatmonth(2015, 1) print str #loop over the days of a month #zeroes indicate that the day of the week is in a next month or overlapping month for i in c.itermonthdays(2015,4): print i #The calendar can give info based on local such a names of days and months (full and abbreviated forms) for name in calendar.month_name: print name for day in calendar.day_name: print day #calculate days based on a rule: For instance an audit day on the second Monday of every month #Figure out what days that would be for each month, we can use the script as shown here for month in range(1,13): # It retrieves a list of weeks that represent the month mycal = calendar.monthcalendar(2020, month) # The second MONDAY has to be within the first two weeks week1 = mycal[1] week2 = mycal[2] if week1[calendar.MONDAY] != 0: auditday = week1[calendar.MONDAY] else: # if the second MONDAY isn't in the first week, it must be in the second week auditday = week2[calendar.MONDAY] print "%10s %2d" % (calendar.month_name[month], auditday)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote