Commit 1d4652a4 authored by Malo KERVESTIN's avatar Malo KERVESTIN
Browse files

maj uml

parent ea9e95dc
......@@ -23,8 +23,8 @@ public class Admin extends Member {
}
public void putOnMarket() { // the administrator can only creat new random cards with random prices
Card new_card = CardController.getInstance().createRandomCard();
Market.getInstance().getBuyableCards().add(new Triple<Card, Integer, User>(new_card,
Card newCard = CardController.getInstance().createRandomCard();
Market.getInstance().getBuyableCards().add(new Triple<Card, Integer, User>(newCard,
new Random().nextInt(1000) + 1, null));
}
......
......@@ -17,7 +17,7 @@ public class CardController {
return instance;
}
public Card controlNbMaxCards(String new_key, int number, Player player, Rarity rarity) {
public Card controlNbMaxCards(String newKey, int number, Player player, Rarity rarity) {
int maxBound = 0;
switch (rarity) {
case COMMON:
......@@ -33,15 +33,15 @@ public class CardController {
break;
}
if (0 < number && number < maxBound) {
Card new_card = new Card(number, rarity, player);
Card newCard = new Card(number, rarity, player);
if (player.getNbCommonCards() < maxBound) {
player.getCards().put(new_key, new_card);
player.getCards().put(newKey, newCard);
player.setNbCommonCards();
} else {
System.err.println("The player " + player.getName() + " has too many " + rarity + " cards");
return null;
}
return new_card;
return newCard;
} else {
System.err.println("Error : card's number incorrect");
return null;
......@@ -50,9 +50,9 @@ public class CardController {
}
public Card createCard(int number, Card.Rarity rarity, Player player) {
String new_key = "" + number + rarity;
if (!player.getCards().containsKey(new_key)) {
return controlNbMaxCards(new_key, number, player, rarity);
String newKey = "" + number + rarity;
if (!player.getCards().containsKey(newKey)) {
return controlNbMaxCards(newKey, number, player, rarity);
} else {
System.err.println("This card already exists");
return null;
......
......@@ -29,9 +29,9 @@ public final class UserController {
public User addUser(String name) {
if (!users.containsKey(name)) {
User new_user = new User(name);
users.put(name, new_user);
return new_user;
User newUser = new User(name);
users.put(name, newUser);
return newUser;
} else {
System.err.println("This user already exists");
return users.get(name);
......@@ -61,15 +61,15 @@ public final class UserController {
public ArrayList<User> rank() {
ArrayList<User> userRank = new ArrayList<User>(users.values());
for (User user : userRank){
for (User user : userRank) {
user.updateTeamScore();
}
Collections.sort(userRank,(a,b) -> Math.round( b.getTeamScore() - (a.getTeamScore())));
Collections.sort(userRank, (a, b) -> Math.round(b.getTeamScore() - (a.getTeamScore())));
System.out.println("### Classement ###");
int i = 1;
for (User user: userRank) {
System.out.println(i + " - " +user.getName() + " : " + user.getTeamScore());
for (User user : userRank) {
System.out.println(i + " - " + user.getName() + " : " + user.getTeamScore());
i++;
}
return userRank;
......
This diff is collapsed.
Supports Markdown
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