How can I modify my program from week 4 to include phone numbers and jersey numbers along with team members name using object-oriented programming?

  

Team Management OOP StyleYour program for keeping track of team members is coming along, but now you want to be able to include phone numbers and jersey numbers along with your team members name. Modify your program from week 4 so that the program utilizes object-oriented programming to create a member object which can accept the players name, phone number, and jersey number. You will need to replace the list with a dictionary to help in locating objects for removal and editing. Again, File Access for long-term storage is not required for this assignment.For this project:You will submit your python code in either the original .py file, or copied into a .txt file.A screenshot of your code having been executed (run). How to Take a ScreenshotTips: While dictionaries resemble lists, remember that they are not the same! It is better to use FOR loops, not WHILE loops with index values.Your class structure does not need a full set of accessor and mutator methods getName(), setName(newName), however it they will be helpful in the next week.Note: I’m enclosing a copy of the week 4 answer you gave me for your reference. Please let me know if you need something else to complete this assignment, Thanks
import sys
members=[]
def printMenu():
print(“===========Main Menu===========”)
print(“1. Display Team Roster.”)
print(“2. Add Member.”)
print(“3. Remove Member.”)
print(“4. Edit Member.”)
print(“9. Exit Program.”)
while True:
printMenu()
sel=int(input(“Selection>”))
if sel==1:
for i in members:
print(i)
if sel==2:
name=input(“Enter new member’s name: “)
members.append(name)
if sel==3:
name=input(“Enter member name to be removed: “)
members.remove(name)
if sel==4:
name=input(“Enter the name of the memeber you want to edit: “)
i=members.index(name)
name2=input(“Enter the new name of the member: “)
members.remove(name)
members.insert(i,name2)
if sel==9:
sys.exit()

Introduction:

Don't use plagiarized sources. Get Your Custom Essay on
How can I modify my program from week 4 to include phone numbers and jersey numbers along with team members name using object-oriented programming?
Just from $13/Page
Order Essay

As a developer, you’ve created a program for keeping track of team members in week 4. Now, you want to modify it to include phone numbers and jersey numbers, all under an object-oriented programming structure. For this project, you’re required to replace the list with a dictionary that is more efficient to locate and manipulate objects. Additionally, this project focuses on utilizing the FOR loops instead of WHILE loops with index values, and there is no need to use file access for long-term storage purposes.

Description:

This project requires you to create a member object that accepts a player’s name, phone number, and jersey number under an object-oriented programming model. You’ll use the program you developed in week 4 as a basis, and modify it to adhere to an OOP structure. You will replace the list with a more efficient dictionary to look up and edit objects. The goal is to create a more robust program that is easier to manipulate. You need to submit your python code in either a .py file or copied into a .txt file. Additionally, you need to attach a screenshot of the program’s output execution. Remember that the class structure doesn’t need a full set of accessor and mutator methods – such as getName(), setName(newName), unless they are required for the next week. Tips to keep in mind are not to use WHILE loops with index values and the best practice is to work with FOR loops. Overall, this project aims to create a clean, efficient program that manages team rosters effectively.

Objectives:

– To modify a Python program from week 4 to utilize object-oriented programming.
– To create a member object that can accept the player’s name, phone number, and jersey number.
– To replace the list with a dictionary to help in locating objects for removal and editing.
– To use FOR loops with dictionaries instead of WHILE loops with index values.

Learning Outcomes:

By the end of this project, learners will be able to:

– Modify existing Python code to use object-oriented programming.
– Create and manipulate Python objects that can accept multiple attributes.
– Use a dictionary to more easily locate and edit objects.
– Understand the key differences between lists and dictionaries in Python.
– Execute Python code and take a screenshot for submission.

Solution 1: Using Object-Oriented Programming to Store Team Members’ Information
To implement the task of storing phone numbers and jersey numbers with the team members’ names, we can create a class called “Member” that will hold the necessary information. We can then use a dictionary to store instances of the Member class, where the keys of the dictionary will be the names of the team members.

Here is the modified code:

“`
import sys

class Member:
def __init__(self, name, phone_number, jersey_number):
self.name = name
self.phone_number = phone_number
self.jersey_number = jersey_number

def __str__(self):
return f”{self.name} ({self.phone_number}), Jersey #: {self.jersey_number}”

members = {}

def printMenu():
print(“===========Main Menu===========”)
print(“1. Display Team Roster.”)
print(“2. Add Member.”)
print(“3. Remove Member.”)
print(“4. Edit Member.”)
print(“9. Exit Program.”)

while True:
printMenu()
sel=int(input(“Selection>”))
if sel==1:
for member in members.values():
print(member)
elif sel==2:
name=input(“Enter new member’s name: “)
phone=input(“Enter new member’s phone number: “)
jersey=input(“Enter new member’s jersey number: “)
members[name] = Member(name, phone, jersey)
elif sel==3:
name=input(“Enter member name to be removed: “)
if name in members:
del members[name]
elif sel==4:
name=input(“Enter the name of the member you want to edit: “)
if name in members:
updated_name = input(“Enter the new name of the member: “)
updated_phone = input(“Enter the new phone number of the member: “)
updated_jersey = input(“Enter the new jersey number of the member: “)
members[updated_name] = Member(updated_name, updated_phone, updated_jersey)
del members[name]
elif sel==9:
sys.exit()
“`

Solution 2: Using Accessor and Mutator Methods in the Member Class
Another solution to storing phone numbers and jersey numbers with team members’ names is to use accessor and mutator methods in the Member class. We can use a list to store instances of the Member class, and then update the relevant information in each instance using the accessor and mutator methods.

Here is the modified code:

“`
import sys

class Member:
def __init__(self, name, phone_number, jersey_number):
self.name = name
self.phone_number = phone_number
self.jersey_number = jersey_number

def getName(self):
return self.name

def setName(self, newName):
self.name = newName

def getPhone(self):
return self.phone_number

def setPhone(self, newPhone):
self.phone_number = newPhone

def getJersey(self):
return self.jersey_number

def setJersey(self, newJersey):
self.jersey_number = newJersey

def __str__(self):
return f”{self.name} ({self.phone_number}), Jersey # {self.jersey_number}”

members = []

def printMenu():
print(“===========Main Menu===========”)
print(“1. Display Team Roster.”)
print(“2. Add Member.”)
print(“3. Remove Member.”)
print(“4. Edit Member.”)
print(“9. Exit Program.”)

while True:
printMenu()
sel=int(input(“Selection>”))
if sel==1:
for member in members:
print(member)
elif sel==2:
name=input(“Enter new member’s name: “)
phone=input(“Enter new member’s phone number: “)
jersey=input(“Enter new member’s jersey number: “)
members.append(Member(name, phone, jersey))
elif sel==3:
name=input(“Enter member name to be removed: “)
for member in members:
if member.getName() == name:
members.remove(member)
break
elif sel==4:
name=input(“Enter the name of the member you want to edit: “)
for member in members:
if member.getName() == name:
updated_name = input(“Enter the new name of the member: “)
updated_phone = input(“Enter the new phone number of the member: “)
updated_jersey = input(“Enter the new jersey number of the member: “)
member.setName(updated_name)
member.setPhone(updated_phone)
member.setJersey(updated_jersey)
break
elif sel==9:
sys.exit()
“`

Both solutions will achieve the task of including phone numbers and jersey numbers along with the team members’ names. However, the implementation can vary based on the needs and preferences of the programmer.

Suggested resources/books:
1. “Python Crash Course, 2nd Edition: A Hands-On, Project-Based Introduction to Programming” by Eric Matthes.
2. “Head First Python, 2nd Edition: A Brain-Friendly Guide” by Paul Barry.
3. “Python for Everybody: Exploring Data in Python 3” by Charles Severance.

Similar asked questions:
1. How can I modify my Python program to use object-oriented programming to create member objects?
2. What is the difference between lists and dictionaries in Python?
3. Should I use FOR loops or WHILE loops with index values?
4. Do I need a full set of accessor and mutator methods for my Python class structure?
5. What is the best way to implement file access for long-term storage in Python?

Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
× How can I help you?