diff --git a/src/main/java/latice/application/LaticeApplicationConsole.java b/src/main/java/latice/application/LaticeApplicationConsole.java index 9e84a85..ad11012 100644 --- a/src/main/java/latice/application/LaticeApplicationConsole.java +++ b/src/main/java/latice/application/LaticeApplicationConsole.java @@ -1,50 +1,40 @@ package latice.application; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Random; import latice.model.Color; +import latice.model.Deck; +import latice.model.Rack; import latice.model.Shape; import latice.model.Tile; public class LaticeApplicationConsole { public static void main(String[] args) { - Tile blueBird = new Tile(Color.BLUE, Shape.BIRD); - Tile greenLeaf = new Tile(Color.GREEN, Shape.LEAF); - Tile redFlower = new Tile(Color.RED, Shape.FLOWER); - ArrayList rackPlayer1 = new ArrayList(); - ArrayList rackPlayer2 = new ArrayList(); - int tilesNumber = 3; + ArrayList listOfTile = new ArrayList(); - ArrayList tiles =new ArrayList(Arrays.asList(blueBird, greenLeaf, redFlower)); + System.out.println("Hello Latice !"); - System.out.println("Hello Latice ! " + blueBird.getShape() + blueBird.getColor()); - System.out.println("Hello Latice ! " + greenLeaf.getShape() + greenLeaf.getColor()); - System.out.println("Hello Latice ! " + redFlower.getShape() + redFlower.getColor()); - System.out.println("Hello Latice ! " + tiles.get(0).getShape() + tiles.get(0).getColor()); - //------------------------------Tiles attribution----------------------------------- - Random random = new Random(); - for(int i=0; i<=tilesNumber; i++) { - if(! tiles.isEmpty()) { - int randomNumber = random.nextInt(tiles.size()); - if(i%2 == 0) { - rackPlayer1.add(tiles.get(randomNumber)); - System.out.println(rackPlayer1.get(0).getColor().toString() + rackPlayer1.get(0).getShape().toString()); - } else { - rackPlayer2.add(tiles.get(randomNumber)); - System.out.println(rackPlayer2.get(0).getColor().toString() + rackPlayer2.get(0).getShape().toString()); - } - tiles.remove(randomNumber); - System.out.println(randomNumber); - System.out.println(rackPlayer1); - System.out.println(rackPlayer2); + for (Color color : Color.values()) { + for (Shape shape : Shape.values()) { + Tile tile = new Tile(color, shape); + + listOfTile.add(tile); + } - } + System.out.println("-----------------"); + System.out.println("Notre Deck :"); + Deck deck = new Deck(listOfTile); + deck.displayListTile(); + System.out.println("-----------------"); + Rack rack = new Rack(deck); + System.out.println("-----------------"); + deck.displayListTile(); + + } diff --git a/src/main/java/latice/model/Deck.java b/src/main/java/latice/model/Deck.java new file mode 100644 index 0000000..39b4449 --- /dev/null +++ b/src/main/java/latice/model/Deck.java @@ -0,0 +1,26 @@ +package latice.model; + +import java.util.ArrayList; + +public class Deck { + private ArrayList deckTile = new ArrayList(); + + public Deck(ArrayList deckTile) { + this.deckTile = deckTile; + } + + public void displayListTile() { + for (Tile tile : deckTile) { + System.out.println("tuile : couleur = " + tile.getColor() + " forme = " + tile.getShape()); + } + + } + + public ArrayList getListTile() { + return this.deckTile; + } + + + + +} diff --git a/src/main/java/latice/model/Rack.java b/src/main/java/latice/model/Rack.java new file mode 100644 index 0000000..36f0e60 --- /dev/null +++ b/src/main/java/latice/model/Rack.java @@ -0,0 +1,28 @@ +package latice.model; + +import java.util.ArrayList; + +public class Rack { + private ArrayList listRackTile = new ArrayList(); + + public Rack(Deck deck) { + System.out.println("Il y a dans le rack : " + listRackTile.size() + " valeurs"); + + for (int i = 0; i < 5; i++) { + int index = (int)(Math.random()*((deck.getListTile()).size()-0+1)+0); //(int)(Math.random()*(max-min+1)+min); + listRackTile.add((deck.getListTile()).get(index)); + System.out.println("l'indice de la tuile ajouté au rack est : " + index + + " qui est la tuile : couleur = " + (deck.getListTile()).get(index).getColor() + + " forme = " + (deck.getListTile()).get(index).getShape()); + deck.getListTile().remove(index); + + } + + System.out.println("Il y a dans le rack : " + listRackTile.size() + " valeurs"); + } + + + // TODO add method(s) javafx + +} + diff --git a/src/main/java/latice/model/Tile.java b/src/main/java/latice/model/Tile.java index 676e9c7..b2ff117 100644 --- a/src/main/java/latice/model/Tile.java +++ b/src/main/java/latice/model/Tile.java @@ -1,19 +1,19 @@ package latice.model; public class Tile { - Color color; - Shape shape; + private final Color color; + private final Shape shape; public Tile(Color color, Shape shape) { this.color = color; this.shape = shape; } - + public Color getColor() { - return color; + return this.color; } - + public Shape getShape() { - return shape; + return this.shape; } }