Question: Write a python class for the test cases def test_Person_class(): john = Person('john', 32) assert(isinstance(john, Person)) assert(john.get_name() == 'john') assert(john.get_age() == 32) # Note: person.get_friends()

Write a python class for the test cases

def test_Person_class(): john = Person('john', 32) assert(isinstance(john, Person)) assert(john.get_name() == 'john') assert(john.get_age() == 32) # Note: person.get_friends() returns a list of Person objects who # are the friends of this person, listed in the order that # they were added. # Note: person.get_friend_names() returns a list of strings, the # names of the friends of this person. This list is sorted! assert(john.get_friends() == [ ]) assert(john.get_friends_names() == [ ])

jade = Person('jade', 35) assert(jade.get_name() == 'jade') assert(jade.get_age() == 35) assert(jade.get_friends() == [ ])

jade.add_friend(john) assert(jade.get_friends() == [john]) assert(jade.get_friends_names() == ['john']) assert(john.get_friends() == [jade]) # friends are mutual! assert(john.get_friends_names() == ['jade']) jade.add_friend(john) assert(jade.get_friends() == [john]) # don't add twice!

joy = Person('joy', 29) john.add_friend(joy) assert(john.get_friends_names() == ['joy', 'jade']) # reminder: friend names are sorted!

may = Person('may', 4) joy.add_friend(may) assert(joy.get_friends_names() == ['john', 'may'])

dino = Person('dino', 28) dino.add_friend(may) dino.add_friend(joy) # Note: different method than before! dino.add_friends(john) # add ALL of John's friends as Dino's friends assert(dino.get_friends() == [may, joy, jade]) assert(dino.get_friends_names() == ['joy', 'may', 'jade'])

john.add_friend(jade) john.add_friend(dino) assert(john.get_friends() == [jade, joy, dino]) assert(john.get_friends_names() == ['dino', 'joy', 'jade']) # sorted! assert(dino.get_friends() == [may, joy, jade, john]) assert(dino.get_friends_names() == ['joy', 'john', 'may', 'jade']) print("done!")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!