code is running perfectly just some bits and pieces should be added to match it similar to the er diagram, fixe the report and make the video presentations clearly pointing out the points and steps, the order and the steps in the code are missing in the attached screenshot as well as fixed the report and write the steps in the code to make the video again. Just to confirm the code is there I need a video presentation of the following final code along with explanation as u can see on the screenshot there some things missing too . Thanks
Software Development final report
Introduction:As a part of the Software Development module this year we have full semester Assessment, from our tutor Paula which was Playlist, song and Artist.
In this Project similarly I have Football Team, Sponsor and Team player in which I have players like Goal Keeper and Striker.
#!/usr/bin/envpython
# coding: utf-8
# In[40]:
# This code contains overloading methods, abstract classes and methods, aggregation relationships between classes and writing
# to json file and reading from json file. Also, the code contains implemented data structures.
importenum
import json
fromabcimport ABC, abstractmethod
classFootballTeam(ABC): # its is now marked as an abstract class
# overriding the _init_function
def__init__(self, name, id , sponsor):
# lab1: declaring instance variables/data members/attributes
self.name = name
self.team_id = id
# Aggregation relationship between Team and sponsor.
self.sponsor = sponsor
self.teamplayers = []
# setter function, to set name.
defsetName(self):
returnself.name
# getter function, to get name.
defgetName(self):
returnself.name
# inserted setter function for setting value of team_id here.
defsetteam_id(self, id):
self.team_id = id
# getter function to get team_id.
defgetteam_id(self):
returnself.team_id
# Inserted setter function for setting vale of sponsor here.
defsetsponsorValue(self, sponsor):
self.sponsor = sponsor
# getter function to get sponsor value.
defgetsponsorValueValue(self):
returnself.sponsor
defgetTeamPlayers(self):
returnself.teamplayers
# Aggregation relationship between FootballTeam and TeamPlayer.
defaddPlayer(self, teamplayer):
self.teamplayers.append(teamplayer)
defremovePlayer(self, teamplayer):
self.teamplayers.remove(teamplayer)
deflistToString(self, s):
str1 = “”
forelein s:
str1 += str(ele) + “\n”
return str1
def__str__(self):
players = self.listToString(self.teamplayers)
returnself.name + ” “ + str(self.team_id) + ” “ + str(self.sponsor) + “\n” + players
classPlayerType():
goal_keeper = 4
stricker = 7
classTeamPlayer(): # Aggregation relationship between TeamPlayer and PlayerType.
def__init__(self, name, playerId, remaining_fees, playerType):
super().__init__()
self.name = name
self.remaining_fees = remaining_fees
self.playerId = playerId
self.playerType = playerType
# declaring mutator (set) &accessor (get) methods for each of the instance variables
defcalcremaining_fees(self, fees):
if fees <1000: # data integrity check for value of f
print(“remaining fees should be 200”)
self.remaining_fees = 1000
returnself.remaining_fees
else:
self.remaining_fees = fees
returnself.remaining_fees
defsetPlayerId(self, playerId):
self.playerId = playerId
defsetName(self, name):
self.name = name
defsetremaining_fees(self, remaining_fees):
self.remaining_fees = remaining_fees
defsetPlayerType(self, PlayerType):
self.playerType = PlayerType
defgetPlayerId(self): # calling the values(lop) of the attributes(listofplayers)
returnself.playerId
defgetName(self): # calling the values(nop) of the attributes(nofplayers)
returnself.name
defgetremaining_fees(self):
returnself.remaining_fees
defgetPlayerType(self):
returnsuper.playerType
def__str__(self):
return” “ + self.name + ” “ + self.playerId + ” “ + self.remaining_fees + ” “ + str(self.playerType)
classsponsor(): # showing 1 to 1 association relationship between classes
# assigning default values for the init parameters
def__init__(self, ValOfsponsorship=0, name=” “, duration=0):
# super().__init__(name, ValOfsponsorship, duration) # calling super method
self.name = name
self.ValOfsponsorship = ValOfsponsorship
self.duration = duration
# inserted all the setters and getters here.
defsetName(self, name):
self.name = name
defgetName(self):
returnself.name
defsetduration(self, duration):
self.duration = duration
defgetduration(self):
returnself.duration
defsetsponsorValue(self, ValOfsponsorship):
self.ValOfsponsorship = ValOfsponsorship
defgetsponsorValue(self):
returnself.ValOfsponsorship
def__str__(self):
return” “ + self.name + ” “ + self.ValOfsponsorship + ” “ + self.duration
teamPlayer1 = TeamPlayer(“LionelMessi“, “3”, “200”, PlayerType.stricker)
teamPlayer2 = TeamPlayer(“PauloDybala“, “2”, “200”, PlayerType.goal_keeper)
teamPlayer3 = TeamPlayer(“SergioAguero“, “1”, “190”, PlayerType.goal_keeper)
teamPlayer4 = TeamPlayer(“LautaroMartinez“, “4”, “40”, PlayerType.stricker)
teamPlayer5 = TeamPlayer(“DiMaria“, “5”, “300”, PlayerType.stricker)
teamPlayer6 = TeamPlayer(“Armani“, “6”, “14”, PlayerType.stricker)
teamPlayer7 = TeamPlayer(“Gomez“, “7”, “60”, PlayerType.stricker)
teamPlayer8 = TeamPlayer(“Juan“, “8”, “55”, PlayerType.stricker)
teamPlayer9 = TeamPlayer(“Dominguez“, “9”, “80”, PlayerType.stricker)
teamPlayer10 = TeamPlayer(“Salvio“, “10”, “660”, PlayerType.stricker)
teamPlayer11 = TeamPlayer(“MustafaT”, “11”, “660”, PlayerType.stricker)
sponsor = sponsor(“50000”, “Redbul“, “3 Games”)
FootballTeam = FootballTeam(“Argentina”, “1”, sponsor)
FootballTeam.addPlayer(teamPlayer1)
FootballTeam.addPlayer(teamPlayer2)
FootballTeam.addPlayer(teamPlayer3)
FootballTeam.addPlayer(teamPlayer4)
FootballTeam.addPlayer(teamPlayer5)
FootballTeam.addPlayer(teamPlayer6)
FootballTeam.addPlayer(teamPlayer7)
FootballTeam.addPlayer(teamPlayer8)
FootballTeam.addPlayer(teamPlayer9)
FootballTeam.addPlayer(teamPlayer10)
FootballTeam.addPlayer(teamPlayer11)
print(FootballTeam)
print(teamPlayer1.calcremaining_fees(250))
# Searching & implemented here to search for teamPlayer, with worst case complexity of O(n)
defsearchForPlayer(self, TeamPlayer):
ifTeamPlayerinself.FootballTeam:
print(teamPlayer1.name + ” is in football team” + FootballTeam.team_id)
else:
print(teamPlayer1.name + ” is not in football team”)
defsortTeam(self): # Sort algorithm is implemented here to sort the football team with aver-duration and worst case complexity of O(n log n)
self.FootballTeam.sort()
defsortedTeam(self): # returns the sorted team.
return sorted(self.FootballTeam)
print(FootballTeam.getName)
playerIdList = [1, 6, 7, 3, 9, 10, 111, 50, 32, 28, 16]
# lambda function used instead of a helper function
result = list(map(lambda s: s.getName(), FootballTeam.teamplayers))
print(result)
# Writing to JSON File
with open(‘data2.json‘, ‘w’) asoutfile:
outfile.write(‘ { ‘)
outfile.write(‘ “player” : [‘)
outfile.write(‘{ “Player name”: ‘)
json.dump(“LionelMessi“, outfile, indent=4)
outfile.write(‘,’)
outfile.write(‘ “Player Id”: ‘)
json.dump(“22”, outfile, indent=4)
outfile.write(‘,’)
outfile.write(‘”remaining fee”:’)
json.dump(“200”, outfile, indent=4)
outfile.write(‘ } ‘)
outfile.write(‘ ] ‘)
outfile.write(‘}’)
playerList = [[‘LionelMessi‘, 3], [‘PauloDybala‘, 2], [‘SergioAguero‘, 1], [‘LautaroMartinez‘, 4], [
‘DiMaria‘, 5], [‘Armani‘, 6], [‘Gomez‘, 7], [‘Juan‘, 8], [‘Dominguez‘, 9], [‘Salvio‘, 10], [‘MT’, 11]]
# SORTING Player on the basis of name
# Using sort() function
playerList.sort()
print(playerList)
# Reading from JSON File
print(‘\n Reading from json file’)
f = open(‘data2.json‘,)
# returns JSON object as
# a dictionary
data = json.load(f)
# Iterating through the json
# list
for i in data[‘player’]:
print(i)
print(‘\n’)
# Closing file
f.close()
# In[ ]:
# In[ ]:
Final Code:
”’
”’
#!/usr/bin/envpython
# coding: utf-8
# In[40]:
# This code contains overloading methods, abstract classes and methods, aggregation relationships between classes and writting
# to json file and reading from json file. Also the code contains implemented data structures.
importenum
import json
fromabcimport ABC, abstractmethod
classFootballTeam(ABC): # is now marked as an abstract class
# overriding the _init_function
def__init__(self, name, id , sponsor):
# lab1: declaring instance variables/data members/attributes
self.name = name
self.team_id = id
# Aggregation relationship between Cricket Team and sponsor.
self.sponsor = sponsor
self.teamplayers = []
# setter function, to set name.
defsetName(self):
returnself.name
# getter function, to get name.
defgetName(self):
returnself.name
# inserted setter function for setting value of team_id here.
defsetteam_id(self, id):
self.team_id = id
# getter function to get team_id.
defgetteam_id(self):
returnself.team_id
# Inserted setter function for setting vale of sponsor here.
defsetsponsorValue(self, sponsor):
self.sponsor = sponsor
# getter function to get sponsor value.
defgetsponsorValueValue(self):
returnself.sponsor
defgetTeamPlayers(self):
returnself.teamplayers
# Aggregation relationship between FootballTeam and TeamPlayer.
defaddPlayer(self, teamplayer):
self.teamplayers.append(teamplayer)
defremovePlayer(self, teamplayer):
self.teamplayers.remove(teamplayer)
deflistToString(self, s):
str1 = “”
forelein s:
str1 += str(ele) + “\n”
return str1
def__str__(self):
players = self.listToString(self.teamplayers)
returnself.name + ” “ + str(self.team_id) + ” “ + str(self.sponsor) + “\n” + players
classPlayerType():
goal_keeper = 4
stricker = 7
classTeamPlayer(): # Aggregation relationship between TeamPlayer and PlayerType.
def__init__(self, name, playerId, remaining_fees, playerType):
super().__init__()
self.name = name
self.remaining_fees = remaining_fees
self.playerId = playerId
self.playerType = playerType
# declaring mutator (set) &accessor (get) methods for each of the instance variables
defcalcremaining_fees(self, fees):
if fees <1000: # data integrity check for value of f
print(“remaining fees should be 200”)
self.remaining_fees = 1000
returnself.remaining_fees
else:
self.remaining_fees = fees
returnself.remaining_fees
defsetPlayerId(self, playerId):
self.playerId = playerId
defsetName(self, name):
self.name = name
defsetremaining_fees(self, remaining_fees):
self.remaining_fees = remaining_fees
defsetPlayerType(self, PlayerType):
self.playerType = PlayerType
defgetPlayerId(self): # calling the values(lop) of the attributes(listofplayers)
returnself.playerId
defgetName(self): # calling the values(nop) of the attributes(nofplayers)
returnself.name
defgetremaining_fees(self):
returnself.remaining_fees
defgetPlayerType(self):
returnsuper.playerType
def__str__(self):
return” “ + self.name + ” “ + self.playerId + ” “ + self.remaining_fees + ” “ + str(self.playerType)
classsponsor(): # showing 1 to 1 association relationship between classes
# assigning default values for the init parameters
def__init__(self, ValOfsponsorship=0, name=” “, duration=0):
# super().__init__(name, ValOfsponsorship, duration) # calling super method
self.name = name
self.ValOfsponsorship = ValOfsponsorship
self.duration = duration
# inserted all the setters and getters here.
defsetName(self, name):
self.name = name
defgetName(self):
returnself.name
defsetduration(self, duration):
self.duration = duration
defgetduration(self):
returnself.duration
defsetsponsorValue(self, ValOfsponsorship):
self.ValOfsponsorship = ValOfsponsorship
defgetsponsorValue(self):
returnself.ValOfsponsorship
def__str__(self):
return” “ + self.name + ” “ + self.ValOfsponsorship + ” “ + self.duration
teamPlayer1 = TeamPlayer(“LionelMessi“, “3”, “200”, PlayerType.stricker)
teamPlayer2 = TeamPlayer(“PauloDybala“, “2”, “200”, PlayerType.goal_keeper)
teamPlayer3 = TeamPlayer(“SergioAguero“, “1”, “190”, PlayerType.goal_keeper)
teamPlayer4 = TeamPlayer(“LautaroMartinez“, “4”, “40”, PlayerType.stricker)
teamPlayer5 = TeamPlayer(“DiMaria“, “5”, “300”, PlayerType.stricker)
teamPlayer6 = TeamPlayer(“Armani“, “6”, “14”, PlayerType.stricker)
teamPlayer7 = TeamPlayer(“Gomez“, “7”, “60”, PlayerType.stricker)
teamPlayer8 = TeamPlayer(“Juan“, “8”, “55”, PlayerType.stricker)
teamPlayer9 = TeamPlayer(“Dominguez“, “9”, “80”, PlayerType.stricker)
teamPlayer10 = TeamPlayer(“Salvio“, “10”, “660”, PlayerType.stricker)
teamPlayer11 = TeamPlayer(“MT”, “11”, “660”, PlayerType.stricker)
sponsor = sponsor(“50000”, “Redbul“, “3 Games”)
FootballTeam = FootballTeam(“Argentina”, “1”, sponsor)
FootballTeam.addPlayer(teamPlayer1)
FootballTeam.addPlayer(teamPlayer2)
FootballTeam.addPlayer(teamPlayer3)
FootballTeam.addPlayer(teamPlayer4)
FootballTeam.addPlayer(teamPlayer5)
FootballTeam.addPlayer(teamPlayer6)
FootballTeam.addPlayer(teamPlayer7)
FootballTeam.addPlayer(teamPlayer8)
FootballTeam.addPlayer(teamPlayer9)
FootballTeam.addPlayer(teamPlayer10)
FootballTeam.addPlayer(teamPlayer11)
print(FootballTeam)
print(teamPlayer1.calcremaining_fees(250))
# Searching algo is implemented here to search for teamPlayer, with worst case complexity of O(n)
defsearchForPlayer(self, TeamPlayer):
ifTeamPlayerinself.FootballTeam:
print(teamPlayer1.name + ” is in football team” + FootballTeam.team_id)
else:
print(teamPlayer1.name + ” is not in football team”)
defsortTeam(self): # Sort algorithm is implemented here to sort the football team with averduration and worst case complexity of O(n log n)
self.FootballTeam.sort()
defsortedTeam(self): # returns the sorted team.
return sorted(self.FootballTeam)
print(FootballTeam.getName)
playerIdList = [1, 6, 7, 3, 9, 10, 111, 50, 32, 28, 16]
# lambda function used instead of a helper function
result = list(map(lambda s: s.getName(), FootballTeam.teamplayers))
print(result)
# Writing to JSON File
with open(‘data2.json‘, ‘w’) asoutfile:
outfile.write(‘ { ‘)
outfile.write(‘ “player” : [‘)
outfile.write(‘{ “Player name”: ‘)
json.dump(“LionelMessi“, outfile, indent=4)
outfile.write(‘,’)
outfile.write(‘ “Player Id”: ‘)
json.dump(“22”, outfile, indent=4)
outfile.write(‘,’)
outfile.write(‘”remaining fee”:’)
json.dump(“200”, outfile, indent=4)
outfile.write(‘ } ‘)
outfile.write(‘ ] ‘)
outfile.write(‘}’)
playerList = [[‘LionelMessi‘, 3], [‘PauloDybala‘, 2], [‘SergioAguero‘, 1], [‘LautaroMartinez‘, 4], [
‘DiMaria‘, 5], [‘Armani‘, 6], [‘Gomez‘, 7], [‘Juan‘, 8], [‘Dominguez‘, 9], [‘Salvio‘, 10], [‘MT’, 11]]
# SORTING Player on the basis of name
# Using sort() function
playerList.sort()
print(playerList)
# Reading from JSON File
print(‘\n Reading from json file’)
f = open(‘data2.json‘,)
# returns JSON object as
# a dictionary
data = json.load(f)
# Iterating through the json
# list
for i in data[‘player’]:
print(i)
print(‘\n’)
# Closing file
f.close()
# In[ ]:
# In[ ]:
#Exception Handling : for working and having Exception handling in our code we first need
#import logging and the import time and then we create logger we than define a function and then
#at last we open a file if there is no file python will give us a error message
“””
import logging
import time
# create logger
logging.basicConfig(filename = “E:\\python_lessons\problems.log”, level = logging.DEBUG)
logger = logging.getLogger()
defread_file_timed(path):
Return the contents of the file at “path” and measure the time reqired.
start_time = time.time()
try:
f = opne(path, mode= “rb“)
data = f.read()
return data
Except FileNotFoundError as error:
logger.error(err)
raise
else:
f.close()
finally:
stop_time = time.time()
dt = stop_time – start_time
logger.info(“Time required for {file} = {time}”, format(file=path,time=dt))
data = read_file_timed(“E:\\python_Lessons\\audio_file.wav”)
“””
Sections for Last Part:
- Require Section : The most complex functions of my project was the sortTeam and searchForplayer this was because it is always hard especially when we add extra bits as well as for the likes of Sponsor because I was really confused at first weather to have Sponsor for team or a player too.
- Design Section:As we were initially thought about Playlist, Song and Playlist, I was also really confused different ideas came and changes but stick with the last one which is the FootballTeam.
What do I have:
Football Team Class:This is the Abstract Class where I have Name, TeamID and Sponsor. The team I have selected for this project is Argentina and there are Eleven (11) players in total consist of Goalkeeper and striker which are the main two players in this project, the class of FootballTeam is consist of NAME, TeamID and Sponsor
Then I have
Aggregation with Sponsor and TeamPlayer:
Sponsor for the FootballTeam:I have set Sponsor for the FootballTeam and there is a cost for the sponsor as well as duration.
Sponsor Class: this class is mainly for the Sponsorship duties, consist of setName, getName, add and remove players from the list, for instance which player should not be in the category in this project the sponsor is two way working, one is as a team and the other is individual, for example which logo and what adverts for them .
Then I have the
TeamPlayer Class: which is off course consist of; name, playerid, remaining fees and playertpe for example in this project I have 11 players but as a sample I am using Goalkeeper and striker which is inherited from TeamPlayer.
Goalkeeper:
I have extended which is consisted of name, setSaves and getSaves this is for how many saves the Goalkeeper did
Striker:more likely the Goalkeeper in job wise but Striker is consisting of name, setGoals and getGoals this is because of the register between the striker and Goalkeeper
- The Calculated Cyclomatic complexity for the two most complex functions of the program:
In my project the most complex part is that it was hard assign the sponsor to the player.
The second part was the assignment of sponsor to the team.
- Traditional Software Development Approach: Key note.
- Requirements
- Analysis and Design
- Development
- Test
- Development and Maintenance
- White box and Black box testing techniques used in the project: Testing based solely on analysis of requirements (specification, user documentation etc, also known as functional testing, black box testing concerns techniques for designing test; it is not a level of testing.
- Whitebox and black box test plan for the two most complex functions of the project: Testing based on analyses of internal logic (design, code, etc). (but expected results still come from requirements.) also known as structural testing, glass box testing and clear box testing
- The test code coverage statistics for the unit test code:
Introduction: Testing is the process of executing a program with the intent of finding errors, a good test case is the one that has a high probability of finding an error and a successful test is the one that uncovers an error
There are three main types of Errors:
- Syntax errors
- Run-time errors and
- Logic errors
Selection of Test Data:It is simply impossible to test every possible input-output combination of the system; there are too many permutations and combinations.To minimize these costs, a goal of testing must be to uncover as many defects as possible with as little testing as possible. The most important factor is the careful selection of input data
•When selecting test data, the following points should be kept in mind:
•1. Choose data for which you can calculate the answer
•2. Choose a variety of different types of data
•3. Select several boundary cases
•4. Choose illegal data
•5. When choosing test data keep in mind that the objective behind
Exception Handling Test
classCustomError(Exception):
pass
randomList = [‘a’, 0, 2]
for entry inrandomList:
try:
print(“The entry is”, entry)
r = 1/int(entry)
#break #this will cause any else clause in the exception handling to be skipped
exceptZeroDivisionErroraszde:
print(“entry cannot be used as it is 0”)
print(zde.__doc__)
exceptValueErrorasve:
print(“entry cannot be used as it is not of the right type”)
print(ve.__doc__)
except Exception as e:
print(“Oops!”, e.__class__, “occurred.”)
print(“Next entry.”)
print()
else:
print(“this will be executed IF there are no exceptions and if there is no break inside the try”)
finally:
print(“this is always executed”)
print(“The reciprocal of”, entry, “is”, r)
try:
# do something
pass
exceptValueError:
# handle ValueError exception
pass
except (TypeError, ZeroDivisionError):
# handle multiple exceptions
# TypeError and ZeroDivisionError
pass
except:
# handle all other exceptions
pass
# program to print the reciprocal of even numbers
try:
num = int(input(“Enter a number: “))
assertnum % 2 == 0
except:
print(“Not an even number!”)
else:
reciprocal = 1/num
print(reciprocal)
A project document with the following sections
requirements section – captured using user stories for the two most complex functions of your project
design section – the updated UML class diagram showing the design of the classes and the relationships between them required for the project
evaluation section – a test plan showing
the calculated cyclomatic complexity for the two most complex functions of the program
white box and black box testing techniques used in the project
white box and black box test plans for the two most complex functions of the project
the test code coverage statistics for the unit test code
The code for the implementation of the project to match the design document and addressing the criteria shown in the table below
A video (max 15 mins) to accompany the project explaining each of the coding criteria as they relate to your project
If you need answers to this assignment, WhatsApp/Text to +1 646 978 1313
or send us an email to admin@shrewdwriters.com and we will reply instantly. We provide original answers that are not plagiarized. Please, try our service. Thanks
Leave a Reply