3.6 Appointments PYTHON
(3 pts) Create a new class called Appointment. An appointment should have a description and a date. Your Appointment class should take the description and date from the constructor and assign them to instance variables.
Your constructor should take parameters in the following order: description, year, month, day.
Your instance variables should be called:
(2 pts) Override the __str__(self) method to print a human-friendly version of the object. Your__str__ method should produce output similar to: Appointment on 1/2/20: Blood pressure check.
(2 pts) Write a main function to test your Appointment class. The main function should prompt the user for a description, month, day, and year; and then print the object to test the __str__ method.
class Appointment: def __init__(self, description, year, month, day): self.description = description self.year = year self.month = month self.day = day def __str__(self): return 'Appointment on {}/{}/{}: {}.'.format(self.month, self.day, self.year, self.description) def main(): description = input("Enter description: ") month = int(input("Enter month: ")) day = int(input("Enter day: ")) year = int(input("Enter year: ")) appointment = Appointment(description, year, month, day) print(appointment) main()
Get Answers For Free
Most questions answered within 1 hours.