Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Party Invitations by ail531
class Friend():
def __init__(self, name_param):
self.name = name_param
self.place_and_time = 'No party...'
def show_invite(self):
return self.place_and_time
class Party():
def __init__(self, place_param):
self.place = place_param
self.list_of_friends = []
def add_friend(self, friend_param):
self.list_of_friends.append(friend_param)
def del_friend(self, friend_param):
self.list_of_friends.remove(friend_param)
def send_invites(self, time_param):
for item in self.list_of_friends:
item.place_and_time = self.place + ': ' + time_param
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
party = Party("Midnight Pub")
nick = Friend("Nick")
john = Friend("John")
lucy = Friend("Lucy")
chuck = Friend("Chuck")
party.add_friend(nick)
party.add_friend(john)
party.add_friend(lucy)
party.send_invites("Friday, 9:00 PM")
party.del_friend(nick)
party.send_invites("Saturday, 10:00 AM")
party.add_friend(chuck)
assert john.show_invite() == "Midnight Pub: Saturday, 10:00 AM"
assert lucy.show_invite() == "Midnight Pub: Saturday, 10:00 AM"
assert nick.show_invite() == "Midnight Pub: Friday, 9:00 PM"
assert chuck.show_invite() == "No party..."
print("Coding complete? Let's try tests!")
Nov. 22, 2019
Comments: