SlideShare a Scribd company logo
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.
****BELOW IS MY CURRENT WORK*** Im having issues printing the data (printmember)
and saving data. Am I using .keys() wrong? using PYTHON
class Team:
members = {}
member = ""
phone = ""
jersey = 0
def __init__(self, member, phone, jersey):
self.member = member
self.phone = phone
self.jersey = jersey
def setmember(self, member):
self.member = member
def setphone(self, phone):
self.phone = phone
def setjersey(self, jersey):
self.jersey = jersey
def getmember(self, member):
return self.member
def getphone(self, phone):
return self.phone
def getjersey(self, jersey):
return self.jersey
def displayData(self):
print("Name : ", self.member)
print("Phone Number : ", self.phone)
print("Jersey Number : ", self.jersey)
def displayMenu():
print("===========Main Menu===========")
print("1. Display Members.")
print("2. Add member")
print("3. Remove member")
print("4. Edit member")
print("5. Save data.")
print("6. Load data.")
print("7. Exit Program")
return int(input("Selection> "))
def printmember(members):
if len(members) == 0:
print("No current members")
else:
for x in members.keys():
members[x].diaplydata()
def addmember(members):
newMember = input("Enter Members Name : ")
newPhone = int(input("Phone Number : "))
newJersey = int(input("Jersey Number : "))
members[newMember] = (newMember, newPhone, newJersey)
print("Member has been added")
return members
def removemember(members):
removemember = input("Please Enter Member to be Removed : ")
if removemember in members:
del members[removemember]
print("Member removed")
else:
print("Member not found.")
return members
def editmember(members):
oldmember = input("Enter the name of the member you want to edit: ")
if oldmember in members:
newmember = input("Enter the members new name : ")
newphone = int(input("Please enter new phone number : "))
newjersey = input("Please enter new Jersey number : ")
members[newmember] = (newmember, newphone, newjersey)
print("Member edited")
else:
print("Member not found")
return members
def saveData(members):
filename = input("Filename to save: ")
print(" Saving file....")
outFile = open("/Users/Randy/Desktop/PYCHARM/Week 6/roster.txt", "wt")
for x in members.keys():
member = members[x].getmember()
phone = members[x].getphone()
jersey = members[x].getjersey()
outFile.write("member , phone , jersey")
print("File saved.")
outFile.close()
return members
def loadData():
members = {}
filename = input("Filename to load: ")
inFile = open("/Users/Randy/Desktop/PYCHARM/Week 6/roster.txt", "rt")
print("Loadng file...")
while True:
inLine = inFile.readline()
if not inLine:
break
inLine = inLine[:-1]
member, phone, jersey = inLine.split(",")
members[member] = Team(member, phone, jersey)
print("File loaded!")
inFile.close()
return members
print("Welcome to Feathers Team Manager")
menuSelection = displayMenu()
choice = 1
while choice:
if menuSelection == 1:
printmember(members)
elif menuSelection == 2:
members = addmember(members)
elif menuSelection == 3:
members = removemember(members)
elif menuSelection == 4:
members = editmember(members)
elif menuSelection == 5:
members = saveData(members)
elif menuSelection == 6:
members = loadData(members)
elif menuSelection == 7:
print("Goodbye!")
exit()
menuSelection = displayMenu()
Solution
class Team:
members = {}
member = ""
phone = ""
jersey = 0
def __init__(self, member, phone, jersey):
self.member = member
self.phone = phone
self.jersey = jersey
def setmember(self, member):
self.member = member
def setphone(self, phone):
self.phone = phone
def setjersey(self, jersey):
self.jersey = jersey
def getmember(self, member):
return self.member
def getphone(self, phone):
return self.phone
def getjersey(self, jersey):
return self.jersey
def displayData(self):
print("Name : ", self.member)
print("Phone Number : ", self.phone)
print("Jersey Number : ", self.jersey)
def displayMenu():
print("===========Main Menu===========")
print("1. Display Members.")
print("2. Add member")
print("3. Remove member")
print("4. Edit member")
print("5. Save data.")
print("6. Load data.")
print("7. Exit Program")
return int(input("Selection> "))
def printmember(members):
if len(members) == 0:
print("No current members")
else:
for x in members.keys():
members[x].diaplydata()
def addmember(members):
newMember = input("Enter Members Name : ")
newPhone = int(input("Phone Number : "))
newJersey = int(input("Jersey Number : "))
members[newMember] = (newMember, newPhone, newJersey)
print("Member has been added")
return members
def removemember(members):
removemember = input("Please Enter Member to be Removed : ")
if removemember in members:
del members[removemember]
print("Member removed")
else:
print("Member not found.")
return members
def editmember(members):
oldmember = input("Enter the name of the member you want to edit: ")
if oldmember in members:
newmember = input("Enter the members new name : ")
newphone = int(input("Please enter new phone number : "))
newjersey = input("Please enter new Jersey number : ")
members[newmember] = (newmember, newphone, newjersey)
print("Member edited")
else:
print("Member not found")
return members
def saveData(members):
filename = input("Filename to save: ")
print(" Saving file....")
outFile = open("/Users/Randy/Desktop/PYCHARM/Week 6/roster.txt", "wt")
for x in members.keys():
member = members[x].getmember()
phone = members[x].getphone()
jersey = members[x].getjersey()
outFile.write("member , phone , jersey")
print("File saved.")
outFile.close()
return members
def loadData():
members = {}
filename = input("Filename to load: ")
inFile = open("/Users/Randy/Desktop/PYCHARM/Week 6/roster.txt", "rt")
print("Loadng file...")
while True:
inLine = inFile.readline()
if not inLine:
break
inLine = inLine[:-1]
member, phone, jersey = inLine.split(",")
members[member] = Team(member, phone, jersey)
print("File loaded!")
inFile.close()
return members
print("Welcome to Feathers Team Manager")
menuSelection = displayMenu()
choice = 1
while choice:
if menuSelection == 1:
printmember(members)
elif menuSelection == 2:
members = addmember(members)
elif menuSelection == 3:
members = removemember(members)
elif menuSelection == 4:
members = editmember(members)
elif menuSelection == 5:
members = saveData(members)
elif menuSelection == 6:
members = loadData(members)
elif menuSelection == 7:
print("Goodbye!")
exit()
menuSelection = displayMenu()

More Related Content

Similar to Until now, you have had to leave your team management program runnin.pdf

Write a task that will perform some of the functions performed by a s.docx
 Write a task that will perform some of the functions performed by a s.docx Write a task that will perform some of the functions performed by a s.docx
Write a task that will perform some of the functions performed by a s.docx
ajoy21
 
Ankit Phadia Hacking tools (2)
Ankit Phadia Hacking tools (2)Ankit Phadia Hacking tools (2)
Ankit Phadia Hacking tools (2)Chandra Pr. Singh
 
Maths with Programming
Maths with ProgrammingMaths with Programming
Maths with Programming
Omar Bashir
 
Write an algorithm for a program that shows the use of all six math fu.docx
Write an algorithm for a program that shows the use of all six math fu.docxWrite an algorithm for a program that shows the use of all six math fu.docx
Write an algorithm for a program that shows the use of all six math fu.docx
karlynwih
 
python_lab_manual_final (1).pdf
python_lab_manual_final (1).pdfpython_lab_manual_final (1).pdf
python_lab_manual_final (1).pdf
keerthu0442
 
RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”
apostlion
 
Python Menu
Python MenuPython Menu
Python Menu
cfministries
 
Python programming workshop session 4
Python programming workshop session 4Python programming workshop session 4
Python programming workshop session 4
Abdul Haseeb
 
1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx
honey690131
 
NOTEPAD MAKING IN PAYTHON BY ROHIT MALAV
NOTEPAD  MAKING IN PAYTHON BY ROHIT MALAVNOTEPAD  MAKING IN PAYTHON BY ROHIT MALAV
NOTEPAD MAKING IN PAYTHON BY ROHIT MALAV
Rohit malav
 
NOTEPAD MAKING IN PAYTHON 2ND PART BY ROHIT MALAV
NOTEPAD MAKING IN PAYTHON 2ND PART BY ROHIT MALAVNOTEPAD MAKING IN PAYTHON 2ND PART BY ROHIT MALAV
NOTEPAD MAKING IN PAYTHON 2ND PART BY ROHIT MALAV
Rohit malav
 
Java Program- Wrtie a Fraction classGiven the main method of a dri.pdf
Java Program- Wrtie a Fraction classGiven the main method of a dri.pdfJava Program- Wrtie a Fraction classGiven the main method of a dri.pdf
Java Program- Wrtie a Fraction classGiven the main method of a dri.pdf
archanaemporium
 
Message, Debugging, File Transfer and Type Group
Message, Debugging, File Transfer and Type GroupMessage, Debugging, File Transfer and Type Group
Message, Debugging, File Transfer and Type Group
sapdocs. info
 
cover every basics of python with this..
cover every basics of python with this..cover every basics of python with this..
cover every basics of python with this..
karkimanish411
 
I really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdfI really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdf
pasqualealvarez467
 
Bangladesh university of business and technology
Bangladesh university of business and technologyBangladesh university of business and technology
Bangladesh university of business and technology
MdmahabuburRahmanLiz
 
python lab programs.pdf
python lab programs.pdfpython lab programs.pdf
python lab programs.pdf
CBJWorld
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
srxerox
 
How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...doughellmann
 
Classes(or Libraries)#include #include #include #include.docx
Classes(or Libraries)#include #include #include #include.docxClasses(or Libraries)#include #include #include #include.docx
Classes(or Libraries)#include #include #include #include.docx
brownliecarmella
 

Similar to Until now, you have had to leave your team management program runnin.pdf (20)

Write a task that will perform some of the functions performed by a s.docx
 Write a task that will perform some of the functions performed by a s.docx Write a task that will perform some of the functions performed by a s.docx
Write a task that will perform some of the functions performed by a s.docx
 
Ankit Phadia Hacking tools (2)
Ankit Phadia Hacking tools (2)Ankit Phadia Hacking tools (2)
Ankit Phadia Hacking tools (2)
 
Maths with Programming
Maths with ProgrammingMaths with Programming
Maths with Programming
 
Write an algorithm for a program that shows the use of all six math fu.docx
Write an algorithm for a program that shows the use of all six math fu.docxWrite an algorithm for a program that shows the use of all six math fu.docx
Write an algorithm for a program that shows the use of all six math fu.docx
 
python_lab_manual_final (1).pdf
python_lab_manual_final (1).pdfpython_lab_manual_final (1).pdf
python_lab_manual_final (1).pdf
 
RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”
 
Python Menu
Python MenuPython Menu
Python Menu
 
Python programming workshop session 4
Python programming workshop session 4Python programming workshop session 4
Python programming workshop session 4
 
1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx
 
NOTEPAD MAKING IN PAYTHON BY ROHIT MALAV
NOTEPAD  MAKING IN PAYTHON BY ROHIT MALAVNOTEPAD  MAKING IN PAYTHON BY ROHIT MALAV
NOTEPAD MAKING IN PAYTHON BY ROHIT MALAV
 
NOTEPAD MAKING IN PAYTHON 2ND PART BY ROHIT MALAV
NOTEPAD MAKING IN PAYTHON 2ND PART BY ROHIT MALAVNOTEPAD MAKING IN PAYTHON 2ND PART BY ROHIT MALAV
NOTEPAD MAKING IN PAYTHON 2ND PART BY ROHIT MALAV
 
Java Program- Wrtie a Fraction classGiven the main method of a dri.pdf
Java Program- Wrtie a Fraction classGiven the main method of a dri.pdfJava Program- Wrtie a Fraction classGiven the main method of a dri.pdf
Java Program- Wrtie a Fraction classGiven the main method of a dri.pdf
 
Message, Debugging, File Transfer and Type Group
Message, Debugging, File Transfer and Type GroupMessage, Debugging, File Transfer and Type Group
Message, Debugging, File Transfer and Type Group
 
cover every basics of python with this..
cover every basics of python with this..cover every basics of python with this..
cover every basics of python with this..
 
I really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdfI really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdf
 
Bangladesh university of business and technology
Bangladesh university of business and technologyBangladesh university of business and technology
Bangladesh university of business and technology
 
python lab programs.pdf
python lab programs.pdfpython lab programs.pdf
python lab programs.pdf
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
 
How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...
 
Classes(or Libraries)#include #include #include #include.docx
Classes(or Libraries)#include #include #include #include.docxClasses(or Libraries)#include #include #include #include.docx
Classes(or Libraries)#include #include #include #include.docx
 

More from pearlcoburnsanche303

Use the following information to answer questions 1-8. -Identify whet.pdf
Use the following information to answer questions 1-8. -Identify whet.pdfUse the following information to answer questions 1-8. -Identify whet.pdf
Use the following information to answer questions 1-8. -Identify whet.pdf
pearlcoburnsanche303
 
What are the various methods for recruiting employees Why are some .pdf
What are the various methods for recruiting employees Why are some .pdfWhat are the various methods for recruiting employees Why are some .pdf
What are the various methods for recruiting employees Why are some .pdf
pearlcoburnsanche303
 
Why is mobile computing so important to these three firms Evaluate .pdf
Why is mobile computing so important to these three firms Evaluate .pdfWhy is mobile computing so important to these three firms Evaluate .pdf
Why is mobile computing so important to these three firms Evaluate .pdf
pearlcoburnsanche303
 
When a heterozygous plant with round seeds is mated to a plant with .pdf
When a heterozygous plant with round seeds is mated to a plant with .pdfWhen a heterozygous plant with round seeds is mated to a plant with .pdf
When a heterozygous plant with round seeds is mated to a plant with .pdf
pearlcoburnsanche303
 
What is the waiting time of each process for each of the scheduling a.pdf
What is the waiting time of each process for each of the scheduling a.pdfWhat is the waiting time of each process for each of the scheduling a.pdf
What is the waiting time of each process for each of the scheduling a.pdf
pearlcoburnsanche303
 
The mayor of a town has proposed a plan for the construction of an a.pdf
The mayor of a town has proposed a plan for the construction of an a.pdfThe mayor of a town has proposed a plan for the construction of an a.pdf
The mayor of a town has proposed a plan for the construction of an a.pdf
pearlcoburnsanche303
 
PROBLEM 5 Find the inverse of each ofthe following z-transforms .pdf
PROBLEM 5 Find the inverse of each ofthe following z-transforms .pdfPROBLEM 5 Find the inverse of each ofthe following z-transforms .pdf
PROBLEM 5 Find the inverse of each ofthe following z-transforms .pdf
pearlcoburnsanche303
 
The Hazen-Williams hydraulic formula for the mass-flow rate, m throug.pdf
The Hazen-Williams hydraulic formula for the mass-flow rate, m throug.pdfThe Hazen-Williams hydraulic formula for the mass-flow rate, m throug.pdf
The Hazen-Williams hydraulic formula for the mass-flow rate, m throug.pdf
pearlcoburnsanche303
 
The first crop produced by african slave labor in the Caribbean was _.pdf
The first crop produced by african slave labor in the Caribbean was _.pdfThe first crop produced by african slave labor in the Caribbean was _.pdf
The first crop produced by african slave labor in the Caribbean was _.pdf
pearlcoburnsanche303
 
The degree of freedom table is available online. Please answer A&B f.pdf
The degree of freedom table is available online. Please answer A&B f.pdfThe degree of freedom table is available online. Please answer A&B f.pdf
The degree of freedom table is available online. Please answer A&B f.pdf
pearlcoburnsanche303
 
the american red cross gives the following distribution for Blood Ty.pdf
the american red cross gives the following distribution for Blood Ty.pdfthe american red cross gives the following distribution for Blood Ty.pdf
the american red cross gives the following distribution for Blood Ty.pdf
pearlcoburnsanche303
 
Suppose that the probability that a head appears when a coin is tosse.pdf
Suppose that the probability that a head appears when a coin is tosse.pdfSuppose that the probability that a head appears when a coin is tosse.pdf
Suppose that the probability that a head appears when a coin is tosse.pdf
pearlcoburnsanche303
 
Suppose a student mbs a Teflon rod with wool and then briefly touches.pdf
Suppose a student mbs a Teflon rod with wool and then briefly touches.pdfSuppose a student mbs a Teflon rod with wool and then briefly touches.pdf
Suppose a student mbs a Teflon rod with wool and then briefly touches.pdf
pearlcoburnsanche303
 
Review the section Investigating Life Clues to the Origin of Langu.pdf
Review the section Investigating Life Clues to the Origin of Langu.pdfReview the section Investigating Life Clues to the Origin of Langu.pdf
Review the section Investigating Life Clues to the Origin of Langu.pdf
pearlcoburnsanche303
 
QUESTION 4 Choose true or false as applicable for each of the.pdf
QUESTION 4 Choose true or false as applicable for each of the.pdfQUESTION 4 Choose true or false as applicable for each of the.pdf
QUESTION 4 Choose true or false as applicable for each of the.pdf
pearlcoburnsanche303
 
Problem 4 Briefly, explain the steps of the Alkaline Lysis “minipre.pdf
Problem 4 Briefly, explain the steps of the Alkaline Lysis “minipre.pdfProblem 4 Briefly, explain the steps of the Alkaline Lysis “minipre.pdf
Problem 4 Briefly, explain the steps of the Alkaline Lysis “minipre.pdf
pearlcoburnsanche303
 
Please explain In a Drosophila dihybrid cross, a sepia male was mate.pdf
Please explain In a Drosophila dihybrid cross, a sepia male was mate.pdfPlease explain In a Drosophila dihybrid cross, a sepia male was mate.pdf
Please explain In a Drosophila dihybrid cross, a sepia male was mate.pdf
pearlcoburnsanche303
 
Ganges River question The Ganges River, shown in Figure 4.57, has an.pdf
Ganges River question The Ganges River, shown in Figure 4.57, has an.pdfGanges River question The Ganges River, shown in Figure 4.57, has an.pdf
Ganges River question The Ganges River, shown in Figure 4.57, has an.pdf
pearlcoburnsanche303
 
Locomotion is important for many Bacteria Which of the following are .pdf
Locomotion is important for many Bacteria Which of the following are .pdfLocomotion is important for many Bacteria Which of the following are .pdf
Locomotion is important for many Bacteria Which of the following are .pdf
pearlcoburnsanche303
 
List the three subpathways of cellular respiration and the results o.pdf
List the three subpathways of cellular respiration and the results o.pdfList the three subpathways of cellular respiration and the results o.pdf
List the three subpathways of cellular respiration and the results o.pdf
pearlcoburnsanche303
 

More from pearlcoburnsanche303 (20)

Use the following information to answer questions 1-8. -Identify whet.pdf
Use the following information to answer questions 1-8. -Identify whet.pdfUse the following information to answer questions 1-8. -Identify whet.pdf
Use the following information to answer questions 1-8. -Identify whet.pdf
 
What are the various methods for recruiting employees Why are some .pdf
What are the various methods for recruiting employees Why are some .pdfWhat are the various methods for recruiting employees Why are some .pdf
What are the various methods for recruiting employees Why are some .pdf
 
Why is mobile computing so important to these three firms Evaluate .pdf
Why is mobile computing so important to these three firms Evaluate .pdfWhy is mobile computing so important to these three firms Evaluate .pdf
Why is mobile computing so important to these three firms Evaluate .pdf
 
When a heterozygous plant with round seeds is mated to a plant with .pdf
When a heterozygous plant with round seeds is mated to a plant with .pdfWhen a heterozygous plant with round seeds is mated to a plant with .pdf
When a heterozygous plant with round seeds is mated to a plant with .pdf
 
What is the waiting time of each process for each of the scheduling a.pdf
What is the waiting time of each process for each of the scheduling a.pdfWhat is the waiting time of each process for each of the scheduling a.pdf
What is the waiting time of each process for each of the scheduling a.pdf
 
The mayor of a town has proposed a plan for the construction of an a.pdf
The mayor of a town has proposed a plan for the construction of an a.pdfThe mayor of a town has proposed a plan for the construction of an a.pdf
The mayor of a town has proposed a plan for the construction of an a.pdf
 
PROBLEM 5 Find the inverse of each ofthe following z-transforms .pdf
PROBLEM 5 Find the inverse of each ofthe following z-transforms .pdfPROBLEM 5 Find the inverse of each ofthe following z-transforms .pdf
PROBLEM 5 Find the inverse of each ofthe following z-transforms .pdf
 
The Hazen-Williams hydraulic formula for the mass-flow rate, m throug.pdf
The Hazen-Williams hydraulic formula for the mass-flow rate, m throug.pdfThe Hazen-Williams hydraulic formula for the mass-flow rate, m throug.pdf
The Hazen-Williams hydraulic formula for the mass-flow rate, m throug.pdf
 
The first crop produced by african slave labor in the Caribbean was _.pdf
The first crop produced by african slave labor in the Caribbean was _.pdfThe first crop produced by african slave labor in the Caribbean was _.pdf
The first crop produced by african slave labor in the Caribbean was _.pdf
 
The degree of freedom table is available online. Please answer A&B f.pdf
The degree of freedom table is available online. Please answer A&B f.pdfThe degree of freedom table is available online. Please answer A&B f.pdf
The degree of freedom table is available online. Please answer A&B f.pdf
 
the american red cross gives the following distribution for Blood Ty.pdf
the american red cross gives the following distribution for Blood Ty.pdfthe american red cross gives the following distribution for Blood Ty.pdf
the american red cross gives the following distribution for Blood Ty.pdf
 
Suppose that the probability that a head appears when a coin is tosse.pdf
Suppose that the probability that a head appears when a coin is tosse.pdfSuppose that the probability that a head appears when a coin is tosse.pdf
Suppose that the probability that a head appears when a coin is tosse.pdf
 
Suppose a student mbs a Teflon rod with wool and then briefly touches.pdf
Suppose a student mbs a Teflon rod with wool and then briefly touches.pdfSuppose a student mbs a Teflon rod with wool and then briefly touches.pdf
Suppose a student mbs a Teflon rod with wool and then briefly touches.pdf
 
Review the section Investigating Life Clues to the Origin of Langu.pdf
Review the section Investigating Life Clues to the Origin of Langu.pdfReview the section Investigating Life Clues to the Origin of Langu.pdf
Review the section Investigating Life Clues to the Origin of Langu.pdf
 
QUESTION 4 Choose true or false as applicable for each of the.pdf
QUESTION 4 Choose true or false as applicable for each of the.pdfQUESTION 4 Choose true or false as applicable for each of the.pdf
QUESTION 4 Choose true or false as applicable for each of the.pdf
 
Problem 4 Briefly, explain the steps of the Alkaline Lysis “minipre.pdf
Problem 4 Briefly, explain the steps of the Alkaline Lysis “minipre.pdfProblem 4 Briefly, explain the steps of the Alkaline Lysis “minipre.pdf
Problem 4 Briefly, explain the steps of the Alkaline Lysis “minipre.pdf
 
Please explain In a Drosophila dihybrid cross, a sepia male was mate.pdf
Please explain In a Drosophila dihybrid cross, a sepia male was mate.pdfPlease explain In a Drosophila dihybrid cross, a sepia male was mate.pdf
Please explain In a Drosophila dihybrid cross, a sepia male was mate.pdf
 
Ganges River question The Ganges River, shown in Figure 4.57, has an.pdf
Ganges River question The Ganges River, shown in Figure 4.57, has an.pdfGanges River question The Ganges River, shown in Figure 4.57, has an.pdf
Ganges River question The Ganges River, shown in Figure 4.57, has an.pdf
 
Locomotion is important for many Bacteria Which of the following are .pdf
Locomotion is important for many Bacteria Which of the following are .pdfLocomotion is important for many Bacteria Which of the following are .pdf
Locomotion is important for many Bacteria Which of the following are .pdf
 
List the three subpathways of cellular respiration and the results o.pdf
List the three subpathways of cellular respiration and the results o.pdfList the three subpathways of cellular respiration and the results o.pdf
List the three subpathways of cellular respiration and the results o.pdf
 

Recently uploaded

The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 

Recently uploaded (20)

The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 

Until now, you have had to leave your team management program runnin.pdf

  • 1. 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. ****BELOW IS MY CURRENT WORK*** Im having issues printing the data (printmember) and saving data. Am I using .keys() wrong? using PYTHON class Team: members = {} member = "" phone = "" jersey = 0 def __init__(self, member, phone, jersey): self.member = member self.phone = phone self.jersey = jersey def setmember(self, member): self.member = member def setphone(self, phone): self.phone = phone def setjersey(self, jersey): self.jersey = jersey def getmember(self, member): return self.member
  • 2. def getphone(self, phone): return self.phone def getjersey(self, jersey): return self.jersey def displayData(self): print("Name : ", self.member) print("Phone Number : ", self.phone) print("Jersey Number : ", self.jersey) def displayMenu(): print("===========Main Menu===========") print("1. Display Members.") print("2. Add member") print("3. Remove member") print("4. Edit member") print("5. Save data.") print("6. Load data.") print("7. Exit Program") return int(input("Selection> ")) def printmember(members): if len(members) == 0: print("No current members") else: for x in members.keys(): members[x].diaplydata() def addmember(members): newMember = input("Enter Members Name : ") newPhone = int(input("Phone Number : ")) newJersey = int(input("Jersey Number : ")) members[newMember] = (newMember, newPhone, newJersey) print("Member has been added") return members def removemember(members): removemember = input("Please Enter Member to be Removed : ") if removemember in members: del members[removemember] print("Member removed")
  • 3. else: print("Member not found.") return members def editmember(members): oldmember = input("Enter the name of the member you want to edit: ") if oldmember in members: newmember = input("Enter the members new name : ") newphone = int(input("Please enter new phone number : ")) newjersey = input("Please enter new Jersey number : ") members[newmember] = (newmember, newphone, newjersey) print("Member edited") else: print("Member not found") return members def saveData(members): filename = input("Filename to save: ") print(" Saving file....") outFile = open("/Users/Randy/Desktop/PYCHARM/Week 6/roster.txt", "wt") for x in members.keys(): member = members[x].getmember() phone = members[x].getphone() jersey = members[x].getjersey() outFile.write("member , phone , jersey") print("File saved.") outFile.close() return members def loadData(): members = {} filename = input("Filename to load: ") inFile = open("/Users/Randy/Desktop/PYCHARM/Week 6/roster.txt", "rt") print("Loadng file...") while True: inLine = inFile.readline() if not inLine: break inLine = inLine[:-1]
  • 4. member, phone, jersey = inLine.split(",") members[member] = Team(member, phone, jersey) print("File loaded!") inFile.close() return members print("Welcome to Feathers Team Manager") menuSelection = displayMenu() choice = 1 while choice: if menuSelection == 1: printmember(members) elif menuSelection == 2: members = addmember(members) elif menuSelection == 3: members = removemember(members) elif menuSelection == 4: members = editmember(members) elif menuSelection == 5: members = saveData(members) elif menuSelection == 6: members = loadData(members) elif menuSelection == 7: print("Goodbye!") exit() menuSelection = displayMenu() Solution class Team: members = {} member = "" phone = "" jersey = 0 def __init__(self, member, phone, jersey): self.member = member self.phone = phone
  • 5. self.jersey = jersey def setmember(self, member): self.member = member def setphone(self, phone): self.phone = phone def setjersey(self, jersey): self.jersey = jersey def getmember(self, member): return self.member def getphone(self, phone): return self.phone def getjersey(self, jersey): return self.jersey def displayData(self): print("Name : ", self.member) print("Phone Number : ", self.phone) print("Jersey Number : ", self.jersey) def displayMenu(): print("===========Main Menu===========") print("1. Display Members.") print("2. Add member") print("3. Remove member") print("4. Edit member") print("5. Save data.") print("6. Load data.") print("7. Exit Program") return int(input("Selection> ")) def printmember(members): if len(members) == 0: print("No current members") else: for x in members.keys(): members[x].diaplydata() def addmember(members): newMember = input("Enter Members Name : ") newPhone = int(input("Phone Number : "))
  • 6. newJersey = int(input("Jersey Number : ")) members[newMember] = (newMember, newPhone, newJersey) print("Member has been added") return members def removemember(members): removemember = input("Please Enter Member to be Removed : ") if removemember in members: del members[removemember] print("Member removed") else: print("Member not found.") return members def editmember(members): oldmember = input("Enter the name of the member you want to edit: ") if oldmember in members: newmember = input("Enter the members new name : ") newphone = int(input("Please enter new phone number : ")) newjersey = input("Please enter new Jersey number : ") members[newmember] = (newmember, newphone, newjersey) print("Member edited") else: print("Member not found") return members def saveData(members): filename = input("Filename to save: ") print(" Saving file....") outFile = open("/Users/Randy/Desktop/PYCHARM/Week 6/roster.txt", "wt") for x in members.keys(): member = members[x].getmember() phone = members[x].getphone() jersey = members[x].getjersey() outFile.write("member , phone , jersey") print("File saved.") outFile.close() return members def loadData():
  • 7. members = {} filename = input("Filename to load: ") inFile = open("/Users/Randy/Desktop/PYCHARM/Week 6/roster.txt", "rt") print("Loadng file...") while True: inLine = inFile.readline() if not inLine: break inLine = inLine[:-1] member, phone, jersey = inLine.split(",") members[member] = Team(member, phone, jersey) print("File loaded!") inFile.close() return members print("Welcome to Feathers Team Manager") menuSelection = displayMenu() choice = 1 while choice: if menuSelection == 1: printmember(members) elif menuSelection == 2: members = addmember(members) elif menuSelection == 3: members = removemember(members) elif menuSelection == 4: members = editmember(members) elif menuSelection == 5: members = saveData(members) elif menuSelection == 6: members = loadData(members) elif menuSelection == 7: print("Goodbye!") exit() menuSelection = displayMenu()