Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Project3_Uno
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9831113
Project3_Uno
Commits
4aeeddde
Commit
4aeeddde
authored
Apr 16, 2020
by
amir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
end and start of a match
parent
c579398c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
3 deletions
+46
-3
Main.java
Main.java
+40
-3
Player.java
Player.java
+6
-0
No files found.
Main.java
View file @
4aeeddde
package
com
.
company
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.Random
;
public
class
Main
{
...
...
@@ -85,14 +86,50 @@ public class Main {
}
//p.printAllCards(i);
}
// first random card from the storage of cards
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
/*
for (int i = 0; i < 4; i++) {
players.get(i).printAllCards(i + 1);
System.out.println(players.get(i).getPlayerPoint());
}
}*/
// first random card from the storage of cards (most be a colored card)
next
=
r
.
nextInt
(
cards
.
size
());
if
(
cards
.
get
(
next
)
instanceof
Black
){
while
(
cards
.
get
(
next
)
instanceof
Black
)
{
next
=
r
.
nextInt
(
cards
.
size
());
}
}
System
.
out
.
println
(
"Player"
+
r
.
nextInt
(
5
)
+
" starts the game"
);
int
move
=
1
;
Player
p
=
null
;
// starts a round
while
(
true
)
{
Iterator
<
Player
>
playerIterator
=
players
.
iterator
();
while
(
playerIterator
.
hasNext
()){
p
=
playerIterator
.
next
();
if
(
p
.
getPlayerCards
().
size
()
==
0
)
break
;
}
if
(
p
.
getPlayerCards
().
size
()
==
0
)
break
;
if
(
move
==
1
)
System
.
out
.
println
(
"Clockwise"
);
else
System
.
out
.
println
(
"CounterClockwise"
);
}
// sort players by each player's point (Acsending sort)
Iterator
<
Player
>
players1
=
players
.
iterator
();
int
min
=
-
1
;
while
(
players1
.
hasNext
()){
p
=
players1
.
next
();
if
(
p
.
getPlayerPoint
()
>
min
)
min
=
p
.
getPlayerPoint
();
}
// end the round by showing each player's point
Iterator
<
Player
>
players2
=
players
.
iterator
();
int
c
=
0
;
while
(
players2
.
hasNext
()){
c
++;
players2
.
next
().
toString
(
c
);
}
// unicode of black color: "\033[0;30m"
// unicode of red color: "\033[0;31m"
// unicode of green color: "\033[0;32m"
...
...
Player.java
View file @
4aeeddde
...
...
@@ -28,4 +28,10 @@ public class Player {
}
return
playerPoint
;
}
public
String
toString
(
int
playerNumber
)
{
return
"Player"
+
playerNumber
+
" {playerPoint="
+
playerPoint
+
" }"
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment