Commit 4aeeddde authored by amir's avatar amir

end and start of a match

parent c579398c
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"
......
......@@ -28,4 +28,10 @@ public class Player {
}
return playerPoint;
}
public String toString(int playerNumber) {
return "Player" + playerNumber +
" {playerPoint=" + playerPoint +
" }";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment