Menu

Leave Team Management Program Running Computer Indefinitely Since Want Lose List Players F Q43783094

Until now, you have had to leave your team management programrunning on your computer indefinitely since you did not want tolose the list of players. Finally, you are ready to add thecomponents to your team management program that will allow you tostore 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:

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

Code to be modified:

#class to hold team member data

class TeamMember():

    #constructor

    def __init__(self,name,jersy,phone):

        self.name = name

        self.jerseyNumber =jersey

        self.phoneNumber =phone

   

    #string representation of object

    def __str__(self):

        return “Name: {},JerseyNumber: {}, Phone: {}”.format(self.name,self.jerseyNumber,self.phoneNumber)

#converted list to dictionary

list = {}

while True:

   print(“Welcome to the Team Manager”)

   print(“============Main Menu=============”)

   print(“1. Display Team Roaster.”)

   print(“2. Add Member.”)

   print(“3. Remove Member.”)

   print(“4. Edit Member.”)

   print(“9. Exit Program.”)

   user_input = int(input(“Selection>”))

   if user_input == 9:

      print(“Exiting Program…”)

      break

   if user_input == 1:

      for i in list:

         print(list[i])

   if user_input == 2:

      #ask the user for name,jersey andphone number

      name = input(“Enter new member’sname: “)

      jersey = input(“Enter newmember’s jersey number: “)

      phone = input(“Enter new member’sphone number: “)

      member =TeamMember(name,jersey,phone)

      if name in list.keys():

         print(“Name already exists!!”)

      else:

          #add nameto the list

         list[name] = member

   if user_input == 3:

      name = input(“Enter member nameto be removed: “)

      #search for the name in thedictionary, if found then delete it

      if name in list.keys():

         dellist[name]

      else:

         print(“Unableto locate ” + name)

   if user_input == 4:

      name = input(“Enter name of themember you want to edit: “)

      #search for the name in thedictionary, if found then ask for the new name, jersey and phonenumber

      if name in list.keys():

        namenew =input(“Enter new name of the member: “)

        jersey = input(“Enternew jersey of the member: “)

        phone = input(“Enternew phone number of the member: “)

        member =list[name];

        del list[name]

        member.name =namenew

        member.jerseyNumber =jersey

        member.phoneNumber =phone

        list[namenew] =member

      else:

         print(“Unableto locate ” + name)

Expert Answer


Answer to Until now, you have had to leave your team management program running on your computer indefinitely since you did not wa…

OR