Commit c579398c authored by amir's avatar amir

point of cards and each player

parent 7eb21396
......@@ -17,4 +17,9 @@ public class Black extends Card {
"blackType=" + blackType +
'}';
}
@Override
public int getCardPoint() {
return 50;
}
}
......@@ -3,7 +3,7 @@ package com.company;
public class Card {
protected String cardColor;
private boolean isSeen = false;
private int cardPoint;
public Card(String color){
this.cardColor = color;
}
......@@ -25,4 +25,8 @@ public class Card {
public void setSeen(boolean seen) {
isSeen = seen;
}
public int getCardPoint() {
return cardPoint;
}
}
......@@ -72,22 +72,27 @@ public class Main {
/*for (int i = 0; i < 108; i++){
System.out.println(cards.get(i).toString());
}*/
Random r = new Random();
Random r = new Random(); int next;
ArrayList<Player> players = new ArrayList<>();
for (int i = 1; i < 5; i++) {
Player p = new Player();
players.add(p);
for (int j = 1; j < 8; j++){
if (cards.get(r.nextInt(108)).isSeen()){
do{
r.nextInt(108);
}while(cards.get(r.nextInt(108)).isSeen());
next = r.nextInt(cards.size());
p.getPlayerCards().add(cards.get(next));
cards.remove(next);
//System.out.println("cardNumber = " + next);
}
p.getPlayerCards().add(cards.get(r.nextInt(108)));
cards.get(r.nextInt(108)).setSeen(false);
//p.printAllCards(i);
}
p.printAllCards(i);
// first random card from the storage of cards
for (int i = 0; i < 4; i++) {
players.get(i).printAllCards(i + 1);
System.out.println(players.get(i).getPlayerPoint());
}
next = r.nextInt(cards.size());
// unicode of black color: "\033[0;30m"
// unicode of red color: "\033[0;31m"
// unicode of green color: "\033[0;32m"
......
......@@ -16,4 +16,9 @@ public class Movemention extends Colored {
public String toString() {
return "cardColor='" + cardColor + '\'' + '}';
}
@Override
public int getCardPoint() {
return 20;
}
}
......@@ -12,4 +12,9 @@ public class Numeric extends Colored {
return "Numeric{ Color=" + cardColor +
", number=" + number + '}';
}
@Override
public int getCardPoint() {
return number;
}
}
......@@ -20,4 +20,12 @@ public class Player {
}
System.out.println();
}
public int getPlayerPoint() {
Iterator<Card> cardIterator = playerCards.iterator();
while (cardIterator.hasNext()){
playerPoint += cardIterator.next().getCardPoint();
}
return 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