Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON ASSIGNMENT Details: 1) Implement a SocialNetworkUser class in the file socialnetworkuser.py according to this UML diagram 2) Write a traditional test file test1.py that

PYTHON ASSIGNMENT

Details:

1) Implement a SocialNetworkUser class in the file socialnetworkuser.py according to this UML diagram image text in transcribed

2) Write a traditional test file test1.py that

* creates a SocialNetworkUser object user,

* prints user and prints the value of each public instance variable of user,

* calls the add_friend method to add "PonyTail" as a friend,

* calls the add_friend method to add "Applejacks" as a friend,

prints the friends instance variable of user.

Hints:

To add a friend to a SocialNetworkUser object, use the list append method in add_friend, not in the test script:

def add_friend(self, the_friend): self.friends.append(the_friend) 

Then you can add two friends like this in test1.py:

snu1.add_friend("PonyTail") snu1.add_friend("AppleJacks") 

If you check the UML diagram for SocialNetworkUser, you see that you are adding the screen names as friends, not actual SocialNetworkUser objects. You can print the friend screen names for a SocialNetworkUser object, say snu1, like this:

for friend in snu1.friends: print(friend) 

The __str__ method for the SocialNetworkUser object should not display the friends of the object. It should just display the fields screen_name, birth_date,relationship_status, and phone_number. The friends are printed like this:

print(snu.friends) 

or

for f in snu.friends: print(f, end=" ") print( )
SocialNetworkUser + screen name str birth_date: str + relationship_status str + phone_number str + friends :S tr init__(self: SocialNetworkUser, screen_name str, birth_date : str, relationship_status: str, phone_number: str) -str(self: SocialNetworkUser) + add friend(self: SocialNetworkUser, the friend: str)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago