Skip to content
Snippets Groups Projects
Commit 32c3348f authored by Runar Halvorsen Indahl's avatar Runar Halvorsen Indahl
Browse files

Enhance/method enhancement

parent 05b0129d
No related branches found
No related tags found
No related merge requests found
...@@ -99,11 +99,14 @@ public class Division { ...@@ -99,11 +99,14 @@ public class Division {
* *
* @return a list of competing teams. * @return a list of competing teams.
*/ */
//TODO: This may have to be altered? public HashMap<String, Team> getCompetingTeams() {
public HashMap<Integer, Team> getCompetingTeams() { HashMap<String, Team> copy = new HashMap<>();
HashMap<Integer, Team> shallowCopy = new HashMap<>();
shallowCopy = (HashMap<Integer, Team>) competingTeams.clone(); for (Team team : competingTeams.values()) {
return shallowCopy; Team deepCopiedTeam = new Team(team.getName(), team.getMembers(), team.isCompeting());
copy.put(deepCopiedTeam.getName(), deepCopiedTeam);
}
return copy;
} }
/** /**
...@@ -123,10 +126,10 @@ public class Division { ...@@ -123,10 +126,10 @@ public class Division {
/** /**
* Gets age group and sex of the division. * Gets age group and sex of the division.
* *
* @return the age group and sex of the division * @return ToString of the division; age group and sex of the division.
*/ */
public DivisionType getDivisionType() { public String getDivisionType() {
return divisionType; return divisionType.toString();
} }
} }
...@@ -23,8 +23,8 @@ class Match { ...@@ -23,8 +23,8 @@ class Match {
private final int fieldNumber; private final int fieldNumber;
private boolean isFinished; private boolean isFinished;
private boolean isWalkover; private boolean isWalkover;
private DivisionType divisionType; private final DivisionType divisionType;
//TODO: Add static unique match id as for class Person? Issue on GitLab.
/** /**
* Instantiates a new Match. * Instantiates a new Match.
* *
...@@ -230,34 +230,17 @@ class Match { ...@@ -230,34 +230,17 @@ class Match {
String walkoverMatch = this.isWalkover() ? "The match is a walkover" : "The match is not a walkover"; String walkoverMatch = this.isWalkover() ? "The match is a walkover" : "The match is not a walkover";
return ( return (
"Match: " + "Match: " +
'\n' + "\n Team 1: " + this.getTeams()[0] +
"Team 1: " + "\n Team 2: " + this.getTeams()[1] +
this.getTeams()[0] + "\n " + refereesString +
'\n' + "\n Score: " + this.getScores() +
"Team 2: " + "\n Start time: " + this.getStartTime() +
this.getTeams()[1] + "\n End time: " + this.getEndTime() +
'\n' + "\n Field number: " + this.getFieldNumber() +
refereesString + "\n " + finishedMatch +
'\n' + "\n " + walkoverMatch +
"Score: " + "\n Match type: " + this.getDivisionType() +
this.getScores() + "\n"
'\n' +
"Start time: " +
this.getStartTime() +
'\n' +
"End time: " +
this.getEndTime() +
'\n' +
"Fieldnumber: " +
this.getFieldNumber() +
'\n' +
finishedMatch +
'\n' +
walkoverMatch +
'\n' +
"Matchtype: " +
this.getDivisionType() +
'\n'
); );
} }
......
...@@ -78,16 +78,9 @@ public class Team { ...@@ -78,16 +78,9 @@ public class Team {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (!(o instanceof Team)) return false; if (!(o instanceof Team team)) return false;
Team team = (Team) o; return (Objects.equals(name, team.name)
return (
isCompeting == team.isCompeting &&
Objects.equals(name, team.name)
); );
} }
@Override
public int hashCode() {
return Objects.hash(name, members, isCompeting);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment