Commit 39008c12 authored by Malo KERVESTIN's avatar Malo KERVESTIN
Browse files

fix conflicts

parent b3e6a266
package game;
public class Admin extends Member{
public class Admin extends Member {
private static Admin instance = null;
public Admin(String name) {
super(name);
private Admin() {
super("admin");
}
public static Admin getInstance() {
if (instance == null) {
instance = new Admin();
}
return instance;
}
}
......@@ -39,14 +39,14 @@ public class Game {
// p.displayCards();
Market market = Market.getInstance();
Admin admin = Admin.getInstance();
cardController.putOnMarket(new Pair<Card, Integer>(card1, 1000));
admin.putOnMarket(new Pair<Card, Integer>(card1, 1000));
market.displayBuyableCards();
p.displayCards();
felix.addCard(card1);
market.displayBuyableCards();
userController.sell();
felix.sell();
felix.displayDeck();
market.displayBuyableCards();
......
......@@ -7,6 +7,10 @@ public class Member {
this.name = name;
}
public void putOnMarket(Pair<Card, Integer> pair) {
Market.getInstance().getBuyableCards().add(pair);
}
public String getName() {
return this.name;
}
......
......@@ -9,7 +9,6 @@ public class Player {
COURT_FIELD_PLAYER,
}
private String name;
private Position position;
private float score;
......@@ -40,6 +39,10 @@ public class Player {
return this.name;
}
public Position getPosition() {
return this.position;
}
public HashMap<String, Card> getCards() {
return this.cards;
}
......
package game;
import java.util.ArrayList;
import java.util.Scanner;
import game.Player.Position;
import game.controllers.CardController;
public class User extends Member {
private int balance;
......@@ -56,4 +58,17 @@ public class User extends Member {
}
}
private Scanner scanner = new Scanner(System.in);
public void sell() {
System.out.println("Which card would you like to sell ?");
displayDeck();
int choice = scanner.nextInt();
Card chosenCard = deck.get(choice);
System.out.println("At which price ?");
int price = scanner.nextInt();
putOnMarket(new Pair<Card, Integer>(chosenCard, price));
System.out.println("Your card is on the market now");
deck.remove(chosenCard);
}
}
\ No newline at end of file
package game.controllers;
import game.Card;
import game.Market;
import game.Player;
import game.Pair;
public class CardController {
private static CardController instance = null;
......@@ -65,8 +63,4 @@ public class CardController {
System.err.println("This card doesn't exist");
}
}
public void putOnMarket(Pair<Card, Integer> pair) {
Market.getInstance().getBuyableCards().add(pair);
}
}
......@@ -59,18 +59,4 @@ public final class UserController {
System.out.println("Disconnexion error : nobody is connected");
}
}
private Scanner scanner = new Scanner(System.in);
public void sell() {
System.out.println("Which card would you like to sell ?");
connectedUser.displayDeck();
int choice = scanner.nextInt();
Card chosenCard = connectedUser.getDeck().get(choice);
System.out.println("At which price ?");
int price = scanner.nextInt();
CardController.getInstance().putOnMarket(new Pair<Card, Integer>(chosenCard, price));
System.out.println("Your card is on the market now");
connectedUser.getDeck().remove(chosenCard);
}
}
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