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