Question: Python - Classes Project. Rules and Restrictions are posted after the question. The main questions needed are __str__, find_invite, find_response, and read_response. Any help is
Python - Classes Project. Rules and Restrictions are posted after the question.
The main questions needed are __str__, find_invite, find_response, and read_response. Any help is greatly appreciated.


class Event: def init__(self, title, invites None, responses-None): create/initialize instance variables for title, invites, and responses. When invites or responses is None, use an empty list as the value. The incoming lists of invites and responses might not have been sorted, but must be sorted as part of this constructor def Hint: when obtaining strings for the lists of invites/responses, how can you rely upon other str definitions to make this a short/trivial method to write? def-repr -str--(self): create/return a string similar to:"""Event('party',J],J])""" * (self): create/return a string identical to the-str-output. * def eq (self, other): determine if this object (self) is equivalent to other (both have same instance variable values). find_invite(self, name): retrieve the Invitation by that name, and return a reference to that Invitation object. When no such invitation is found, this method will raise an InviteNotFoundError pop invite(self, name): retrieve and remove the invitation by the given name from the list of invites, and return it. Any Responses of the same name should be discarded. When no such invitation is found, this method will raise an InviteNotFoundError add_invite(self, inv): add this invitation to the event's list of invites; the list must be sorted before returning. If there is already an invitation by that name, discard the previous one. Hint: use sort() find_response (self, name): retrieve the Response by that name, and return a reference to that Response object. When no such response is found, this method will raise a LookupError such as the following: "no Response found with name-'Alice'." pop_response (self, name): retrieve and remove the response by the given name from the list of responses, and return it. When no such response is found, it will raise a LookupError as follows "no Response found with name-'Alice'." read_response (self, response): check the response, and possibly add it to the list of responses, according to the following rules: o If the name wasn't on the invitation list, raise an InviteNotFoundError out of the method. o When the response indicates more attending than invited, raise a TooManyError out of the method. o When the previous two errors are avoided, add response to the list (removing any old ones by that name) o Th o When the response indi e responses list must be sorted before returning. cates not attending, replace its num_a ttending with e count_attendees (self): return how many people are currently attending, according to the responses list. count_pending(self): return how many inviteds' invitations have no corresponding response. max_attendance(self): return the highest number of attendees, if all remaining unanswered invitations responded 'yes' with the full number of invited. count_rejections (self): Count how many responses indicated not coming (how many invited people are not coming, not just how many rejection responses were received some are "no" responses, others are bringing less than invited). All responses should have been validated when added, so if a response has no associated invitation, behavior is undefined (you don't have to consider the situation, and whatever your program specs in the future!). does in these situations is acceptable; this is the normal idea of "undefined behavior", look for it in rescind_invitation(self, name): we've decided a person is no longer invited to our party; find and remove the invitation by that name from this event, as well as any response they may have sent. This method raises no errors when invitations or responses weren't found. Hint: use exception handling to make this a simple function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
