Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
idatt1002_2022_K1-G4
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carl Gützkow
idatt1002_2022_K1-G4
Commits
de1103be
Commit
de1103be
authored
3 years ago
by
Brage Halvorsen Kvamme
Browse files
Options
Downloads
Patches
Plain Diff
feat(update): Added second constructor in Match and Team.
parent
d92478ec
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/edu/ntnu/idatt1002/k1g4/Match.java
+30
-2
30 additions, 2 deletions
src/main/java/edu/ntnu/idatt1002/k1g4/Match.java
src/main/java/edu/ntnu/idatt1002/k1g4/Team.java
+18
-5
18 additions, 5 deletions
src/main/java/edu/ntnu/idatt1002/k1g4/Team.java
with
48 additions
and
7 deletions
src/main/java/edu/ntnu/idatt1002/k1g4/Match.java
+
30
−
2
View file @
de1103be
...
...
@@ -10,8 +10,8 @@ import java.util.Objects;
/**
* The class Match creates an instance of a match.
*
* @author Callum Gran
* @version 0.
1
* @author Callum Gran
, Brage H. Kvamme
* @version 0.
2
*/
public
class
Match
{
...
...
@@ -55,6 +55,34 @@ public class Match {
this
.
isWalkover
=
isWalkover
;
}
/**
* Instantiates a new Match.
*
* @param team1 Competing team 1.
* @param team2 Competing team 2.
* @param fieldNumber The field that the match is played on.
* @throws IllegalArgumentException thrown if field number is negative
* ,if the teams are the same,
* if one of the teams is not competing or if endTime is before starTime.
* @throws NullPointerException thrown if either team is null or matchType is null
*/
public
Match
(
Team
team1
,
Team
team2
,
LocalDateTime
startTime
,
LocalDateTime
endTime
,
int
fieldNumber
)
throws
IllegalArgumentException
,
NullPointerException
{
if
(
fieldNumber
<
0
)
throw
new
IllegalArgumentException
(
"There should be no negative field numbers"
);
if
(
team1
==
null
||
team2
==
null
)
throw
new
NullPointerException
(
"Team is not defined"
);
if
(
team1
.
equals
(
team2
))
throw
new
IllegalArgumentException
(
"Teams cannot be the same"
);
if
(!
team1
.
isCompeting
()
||
!
team2
.
isCompeting
())
throw
new
IllegalArgumentException
(
"teams must be competing"
);
if
(
endTime
.
isBefore
(
startTime
))
throw
new
IllegalArgumentException
(
"End time cannot be before start time"
);
this
.
teams
=
new
Team
[]
{
team1
,
team2
};
this
.
referees
=
new
HashMap
<>();
this
.
score
=
new
int
[]
{
0
,
0
};
this
.
startTime
=
startTime
;
this
.
endTime
=
endTime
;
this
.
fieldNumber
=
fieldNumber
;
this
.
isFinished
=
false
;
this
.
isWalkover
=
false
;
}
/**
* adds score to a team
* @param teamToAddScore team which score will increase
...
...
This diff is collapsed.
Click to expand it.
src/main/java/edu/ntnu/idatt1002/k1g4/Team.java
+
18
−
5
View file @
de1103be
...
...
@@ -8,8 +8,8 @@ import java.util.Objects;
/**
* The type Team.
*
* @author Callum Gran, Runar Indahl, Nicolai H. Brand
.
* @version 0.
2
* @author Callum Gran, Runar Indahl, Nicolai H. Brand
, Brage H. Kvame
* @version 0.
3
*/
public
class
Team
{
...
...
@@ -36,9 +36,9 @@ public class Team {
/**
* Instantiates a new Team.
*
* @param name the name
* @param isCompeting
the is
competing
* @throws IllegalArgumentException the illegal argument exception
* @param name the name
of the team
* @param isCompeting
is this team
competing
or not?
* @throws IllegalArgumentException the illegal argument exception
is thrown when the name is blank.
*/
public
Team
(
String
name
,
boolean
isCompeting
)
throws
IllegalArgumentException
{
if
(
name
.
isBlank
())
throw
new
IllegalArgumentException
(
"Team needs a name"
);
...
...
@@ -47,6 +47,19 @@ public class Team {
this
.
isCompeting
=
isCompeting
;
}
/**
* Instantiates a new Team. This team is competing has the isCompeting status set to true by default.
*
* @param name The name of the team
* @throws IllegalArgumentException the illegal argument exception is thrown when the name is blank.
*/
public
Team
(
String
name
)
throws
IllegalArgumentException
{
if
(
name
.
isBlank
())
throw
new
IllegalArgumentException
(
"Team needs a name"
);
this
.
name
=
name
;
this
.
members
=
new
HashMap
<>();
this
.
isCompeting
=
true
;
}
/**
* Gets the team name.
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment