CS192 Grantham Team Management Program Part 3 Python Code Assignment attached if what I have so far. I cannot get the file to save or load! help!! Team Ma

CS192 Grantham Team Management Program Part 3 Python Code Assignment attached if what I have so far. I cannot get the file to save or load! help!!

Team Management Part Three

Until now, you have had to leave your team management program running on your computer indefinitely since you did not want to lose the list of players. Finally, you are ready to add the components to your team management program that will allow you to store the player’s information on your computer’s hard drive, thus, allow you to shut down your program without losing your data.

You will need to modify your program to:

include a Save option in the main menu which will prompt the program to write the player’s data to a text file.
modify the startup code so that the program calls a function that reads the player’s data from the text file into the list of member objects.

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 Screenshot

Tips: Think about how you are going to write the data to the text file when you create the load function. Your write function needs to read in the data in the same pattern as the load function, otherwise the data will get jumbled.

Sample output:

C:>python week6.py

Welcome to the Team Manager

===========Main Menu===========

1. Display Team Roster.

2. Add Member.

3. Remove Member.

4. Edit Member.

5. Save Data.

6. Load Data.

9. Exit Program.

Selection> 2

Enter new member’s name: Nathan

Contact phone number: 505-908-0670

Jersey number: 21

===========Main Menu===========

1. Display Team Roster.

2. Add Member.

3. Remove Member.

4. Edit Member.

5. Save Data.

6. Load Data.

9. Exit Program.

Selection> 2

Enter new member’s name: Bobby

Contact phone number: 541-241-0670

Jersey number: 44

===========Main Menu===========

1. Display Team Roster.

2. Add Member.

3. Remove Member.

4. Edit Member.

5. Save Data.

6. Load Data.

9. Exit Program.

Selection> 5

Filename to save: members.txt

Saving data…

Data saved.

===========Main Menu===========

1. Display Team Roster.

2. Add Member.

3. Remove Member.

4. Edit Member.

5. Save Data.

6. Load Data.

9. Exit Program.

Selection> 9

Exiting Program…

C:>python week6.py

Welcome to the Team Manager

===========Main Menu===========

1. Display Team Roster.

2. Add Member.

3. Remove Member.

4. Edit Member.

5. Save Data.

6. Load Data.

9. Exit Program.

Selection> 1

No current members in memory.

===========Main Menu===========

1. Display Team Roster.

2. Add Member.

3. Remove Member.

4. Edit Member.

5. Save Data.

6. Load Data.

9. Exit Program.

Selection> 6

Filename to load: members.txt

Loading data…

Data Loaded Successfully.

===========Main Menu===========

1. Display Team Roster.

2. Add Member.

3. Remove Member.

4. Edit Member.

5. Save Data.

6. Load Data.

9. Exit Program.

Selection> 1

Name: Bobby

Phone: 541-241-0670

Jersey Number: 44

Name: Nathan

Phone: 505-908-0670

Jersey Number: 21

===========Main Menu===========

1. Display Team Roster.

2. Add Member.

3. Remove Member.

4. Edit Member.

5. Save Data.

6. Load Data.

9. Exit Program.

Selection>9

Exiting Program… print( “Welcome to Your Team Management Program!” )
dict_member = {}
class Players:
def __init__(self, name, phone, jersey):
self.name = name
self.phone = phone
self.jersey = jersey
def add(self):
name = input( “Enter new player’s name: ” )
phone = input( “Enter new player’s phone number: ” )
jersey = input( “Enter new players’s jersey number:” )
dict_member[name] = Players( name, phone, jersey )
def display(self):
print( ‘Printing current playersn’ )
print( “Player NametPhone Number t Jersey Number” )
for name, player in dict_member.items():
print( player.name + ‘ t ‘ + player.phone + ‘ tt ‘ +
player.jersey )
def rem(self, name):
if name in dict_member:
del dict_member[name]
def mod(self, name):
if name in dict_member:
newName = input( “Enter player’s new name: ” )
newPhone = input( “Enter player’s new phone number:” )
newJersey = input( “Enter player’s new jersey number:” )
del dict_member[name]
dict_member[newName] = Players( newName, newPhone, newJersey )
else:
print( name + ” does not exist” )
def setname(self, name):
self.name = name
def setphone(self, phone):
self.phone = phone
def setjersey(self, jersey):
self.jersey = jersey
def getname(self):
return self.name
def getphone(self):
return self.phone
def getjersey_number(self):
return self.jersey
choice = 1
player_instance = Players( None, None, None )
while choice:
print( ‘===========Main Menu===========’ )
print( ‘1. Display Team Roster.’ )
print( ‘2. Add Player.’ )
print( ‘3. Remove Player.’ )
print( ‘4. Edit Player.’ )
print( ‘5. Save Data.’ )
print( ‘6. Load Data.’ )
print( ‘9. Exit Program.’ )
choice = int( input( “Enter choice: ” ) )
if choice == 1:
player_instance.display()
elif choice == 2:
player_instance.add()
elif choice == 3:
name = input( ‘Enter players name to be removed: ‘ )
player_instance.rem( name )
elif choice == 4:
name = input( ‘Enter the name of the player you want to edit: ‘ )
player_instance.mod( name )
elif choice == 5:
print( input( “Filename to Save:” ) )
print( “Saving Data…” )
def saveData(players):
filename = input( “Filename to save:” )
outFile = open( “C:data”, “wt”)
outFile.write( filename,)
contents = inFile.read()
for x in players.keys():
name = name[x].getname()
phone = str( name[x].getphone() )
jersey = str( name[x].getjersery() )
outFile.write( name + “,” + phone + “,” + jersey + “n” )
outFile.close()
print( “Data Saved!” )
elif choice == 6:
print( input( “Filename to load: ” ) )
print( “Loading Data… Please Wait.” )
def loadData():
dict_member = {}
inFile = open( “C:data”, “rt” )
contents = inFile.read()
print( contents )
while True:
# read in a line of text from the text file
inFile =
open( “C:/Users/Holly/Desktop/Education/CS192/name_list.txt”, “rt” )
inLine = inFile.readline()
# if line is empty, stop loading data.
if not inLine:
break
inLine = inLine[:-1]
name, phone, jersey, = inLine.split( “name, phone, jersey” )
dict_member[name] = Players( name, phone, jersey )
print( “Data Loaded Successfully!” )
inFile = open( “C:/Users/Holly/Desktop/Education/CS192/name_list.txt”,
“rt” )
inFile.close()
elif choice == 9:
print( ‘Exiting program… Have a great day!n’ )
exit()
else:
print( ‘Sorry, this is an incorrect selection. Please try again. n’ )

Purchase answer to see full
attachment

"Order a similar paper and get 100% plagiarism free, professional written paper now!"

Order Now