Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
briscola-con-vale
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
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
valeria.destasio@studenti.unimi.it
briscola-con-vale
Commits
30e1936c
Commit
30e1936c
authored
Nov 20, 2023
by
giovanni.novati@studenti.unimi.it
Browse files
Options
Downloads
Patches
Plain Diff
REFACTORING: rimossi i TODO. Specificato la classe nel comparable
parent
54d4cc69
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/it/unimi/di/sweng/briscola/Player.java
+3
-7
3 additions, 7 deletions
src/main/java/it/unimi/di/sweng/briscola/Player.java
src/test/java/it/unimi/di/sweng/briscola/PlayerTest.java
+5
-5
5 additions, 5 deletions
src/test/java/it/unimi/di/sweng/briscola/PlayerTest.java
with
8 additions
and
12 deletions
src/main/java/it/unimi/di/sweng/briscola/Player.java
+
3
−
7
View file @
30e1936c
...
...
@@ -7,11 +7,7 @@ import java.util.Collections;
import
java.util.Iterator
;
import
java.util.List
;
public
class
Player
implements
Iterable
<
Card
>,
Comparable
{
// TODO rendere la classe Comparable con altri Player confrontando i punteggi
// TODO rendere la classe Iterable sulle carte che ha in mano
public
class
Player
implements
Iterable
<
Card
>,
Comparable
<
Player
>
{
private
@NotNull
final
String
name
;
private
@NotNull
final
List
<
Card
>
cards
=
new
ArrayList
<>();
private
@NotNull
final
List
<
Card
>
personalDeck
=
new
ArrayList
<>();
...
...
@@ -92,7 +88,7 @@ public class Player implements Iterable<Card>, Comparable {
}
@Override
public
int
compareTo
(
@NotNull
Object
o
)
{
return
getPoints
()
-
((
P
layer
)
o
)
.
getPoints
();
public
int
compareTo
(
@NotNull
Player
player
)
{
return
getPoints
()
-
p
layer
.
getPoints
();
}
}
This diff is collapsed.
Click to expand it.
src/test/java/it/unimi/di/sweng/briscola/PlayerTest.java
+
5
−
5
View file @
30e1936c
...
...
@@ -11,22 +11,22 @@ import static org.assertj.core.api.Assertions.assertThat;
import
static
org
.
mockito
.
Mockito
.
mock
;
public
class
PlayerTest
{
@Test
void
iterablePlayerTest
(){
Player
pl1
=
new
Player
(
"Gio"
);
List
<
Card
>
cards
=
List
.
of
(
Card
.
get
(
Rank
.
ASSO
,
Suit
.
BASTONI
),
Card
.
get
(
Rank
.
ASSO
,
Suit
.
COPPE
),
Card
.
get
(
Rank
.
TRE
,
Suit
.
BASTONI
));
for
(
Card
card
:
cards
)
{
for
(
Card
card
:
cards
)
pl1
.
giveCard
(
card
);
}
Iterator
<
Card
>
it
=
pl1
.
iterator
();
for
(
Card
card
:
cards
)
{
for
(
Card
card
:
cards
)
assertThat
(
card
).
isEqualTo
(
it
.
next
());
}
}
@Test
void
comparePlayerTest
(){
...
...
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