Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
ohj2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
nikkijax
ohj2
Commits
3ae7106d
Commit
3ae7106d
authored
11 months ago
by
thmustap
Browse files
Options
Downloads
Patches
Plain Diff
Testit Pelaajat-luokkaan.
parent
cff4daca
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/HT/fx/Pelaajat.java
+13
-13
13 additions, 13 deletions
src/HT/fx/Pelaajat.java
src/HT/fx/test/PelaajatTest.java
+15
-21
15 additions, 21 deletions
src/HT/fx/test/PelaajatTest.java
with
28 additions
and
34 deletions
src/HT/fx/Pelaajat.java
+
13
−
13
View file @
3ae7106d
...
...
@@ -36,20 +36,20 @@ public class Pelaajat {
* <pre name="test">
* #THROWS SailoException
* Pelaajat pelaajat = new Pelaajat();
* Pelaaja aku1 = new Pelaaja(), aku2 = new Pelaaja();
* Pelaaja aku1 = new Pelaaja(), aku2 = new Pelaaja(), aku3 = new Pelaaja();
* aku1.rekisteroi();
* aku2.rekisteroi();
* aku3.rekisteroi();
* pelaajat.getLkm() === 0;
* pelaajat.lisaa(aku1); pelaajat.getLkm() === 1;
* pelaajat.lisaa(aku2); pelaajat.getLkm() === 2;
* pelaajat.lisaa(aku1); pelaajat.getLkm() === 3;
* pelaajat.anna(0) === aku1;
* pelaajat.anna(1) === aku2;
* pelaajat.anna(2) === aku1;
* pelaajat.anna(1) == aku1 === false;
* pelaajat.anna(1) == aku2 === true;
* pelaajat.anna(3) === aku1; #THROWS IndexOutOfBoundsException
* pelaajat.lisaa(aku1); pelaajat.getLkm() === 4;
* pelaajat.lisaa(aku1); pelaajat.getLkm() === 5;
* pelaajat.lisaa(aku1); #THROWS SailoException
* pelaajat.lisaa(aku3); pelaajat.getLkm() === 3;
* pelaajat.anna(1) === aku1;
* pelaajat.anna(2) === aku2;
* pelaajat.anna(3) === aku3;
* pelaajat.anna(2) == aku1 === false;
* pelaajat.anna(2) == aku2 === true;
* pelaajat.poistaPelaaja(aku3); pelaajat.getLkm() === 2;
* </pre>
*/
public
void
lisaa
(
Pelaaja
pelaaja
)
throws
SailoException
{
...
...
@@ -151,11 +151,11 @@ public class Pelaajat {
}
/**
* Käydään taulukko lä
'
pi ja luodaan uusi ilman poistettavaa pelaajaa
* Käydään taulukko läpi ja luodaan uusi ilman poistettavaa pelaajaa
* @param pel pelaaja joka poistetaan
*/
public
void
poistaPelaaja
(
Pelaaja
pel
)
{
poistaPelaajanOttelut
(
pel
);
//
poistaPelaajanOttelut(pel);
Pelaaja
alkiot2
[]
=
new
Pelaaja
[
lkm
-
1
];
int
i
=
0
;
int
n
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/HT/fx/test/PelaajatTest.java
+
15
−
21
View file @
3ae7106d
...
...
@@ -7,7 +7,7 @@ import HT.fx.*;
/**
* Test class made by ComTest
* @version 2024.0
4.29 12:13:39
// Generated by ComTest
* @version 2024.0
5.09 11:54:44
// Generated by ComTest
*
*/
@SuppressWarnings
({
"all"
})
...
...
@@ -23,25 +23,19 @@ public class PelaajatTest {
@Test
public
void
testLisaa36
()
throws
SailoException
{
// Pelaajat: 36
Pelaajat
pelaajat
=
new
Pelaajat
();
Pelaaja
aku1
=
new
Pelaaja
(),
aku2
=
new
Pelaaja
();
assertEquals
(
"From: Pelaajat line: 40"
,
0
,
pelaajat
.
getLkm
());
pelaajat
.
lisaa
(
aku1
);
assertEquals
(
"From: Pelaajat line: 41"
,
1
,
pelaajat
.
getLkm
());
pelaajat
.
lisaa
(
aku2
);
assertEquals
(
"From: Pelaajat line: 42"
,
2
,
pelaajat
.
getLkm
());
pelaajat
.
lisaa
(
aku1
);
assertEquals
(
"From: Pelaajat line: 43"
,
3
,
pelaajat
.
getLkm
());
assertEquals
(
"From: Pelaajat line: 44"
,
aku1
,
pelaajat
.
anna
(
0
));
assertEquals
(
"From: Pelaajat line: 45"
,
aku2
,
pelaajat
.
anna
(
1
));
assertEquals
(
"From: Pelaajat line: 46"
,
aku1
,
pelaajat
.
anna
(
2
));
assertEquals
(
"From: Pelaajat line: 47"
,
false
,
pelaajat
.
anna
(
1
)
==
aku1
);
assertEquals
(
"From: Pelaajat line: 48"
,
true
,
pelaajat
.
anna
(
1
)
==
aku2
);
try
{
assertEquals
(
"From: Pelaajat line: 49"
,
aku1
,
pelaajat
.
anna
(
3
));
fail
(
"Pelaajat: 49 Did not throw IndexOutOfBoundsException"
);
}
catch
(
IndexOutOfBoundsException
_e_
){
_e_
.
getMessage
();
}
pelaajat
.
lisaa
(
aku1
);
assertEquals
(
"From: Pelaajat line: 50"
,
4
,
pelaajat
.
getLkm
());
pelaajat
.
lisaa
(
aku1
);
assertEquals
(
"From: Pelaajat line: 51"
,
5
,
pelaajat
.
getLkm
());
try
{
pelaajat
.
lisaa
(
aku1
);
fail
(
"Pelaajat: 52 Did not throw SailoException"
);
}
catch
(
SailoException
_e_
){
_e_
.
getMessage
();
}
Pelaaja
aku1
=
new
Pelaaja
(),
aku2
=
new
Pelaaja
(),
aku3
=
new
Pelaaja
();
aku1
.
rekisteroi
();
aku2
.
rekisteroi
();
aku3
.
rekisteroi
();
assertEquals
(
"From: Pelaajat line: 43"
,
0
,
pelaajat
.
getLkm
());
pelaajat
.
lisaa
(
aku1
);
assertEquals
(
"From: Pelaajat line: 44"
,
1
,
pelaajat
.
getLkm
());
pelaajat
.
lisaa
(
aku2
);
assertEquals
(
"From: Pelaajat line: 45"
,
2
,
pelaajat
.
getLkm
());
pelaajat
.
lisaa
(
aku3
);
assertEquals
(
"From: Pelaajat line: 46"
,
3
,
pelaajat
.
getLkm
());
assertEquals
(
"From: Pelaajat line: 47"
,
aku1
,
pelaajat
.
anna
(
1
));
assertEquals
(
"From: Pelaajat line: 48"
,
aku2
,
pelaajat
.
anna
(
2
));
assertEquals
(
"From: Pelaajat line: 49"
,
aku3
,
pelaajat
.
anna
(
3
));
assertEquals
(
"From: Pelaajat line: 50"
,
false
,
pelaajat
.
anna
(
2
)
==
aku1
);
assertEquals
(
"From: Pelaajat line: 51"
,
true
,
pelaajat
.
anna
(
2
)
==
aku2
);
pelaajat
.
poistaPelaaja
(
aku3
);
assertEquals
(
"From: Pelaajat line: 52"
,
2
,
pelaajat
.
getLkm
());
}
// Generated by ComTest END
}
\ No newline at end of file
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