diff --git a/src/main/java/latice/application/LaticeApplicationConsole.java b/src/main/java/latice/application/LaticeApplicationConsole.java index 5f94db2..ad11012 100644 --- a/src/main/java/latice/application/LaticeApplicationConsole.java +++ b/src/main/java/latice/application/LaticeApplicationConsole.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import latice.model.Color; import latice.model.Deck; +import latice.model.Rack; import latice.model.Shape; import latice.model.Tile; @@ -18,18 +19,20 @@ public class LaticeApplicationConsole { for (Color color : Color.values()) { for (Shape shape : Shape.values()) { Tile tile = new Tile(color, shape); - System.out.println("tuile : couleur = " + tile.getColor() + " forme = " + tile.getShape()); + listOfTile.add(tile); } } - + System.out.println("-----------------"); System.out.println("Notre Deck :"); Deck deck = new Deck(listOfTile); - deck.getListTile(); + 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 index df59de1..39b4449 100644 --- a/src/main/java/latice/model/Deck.java +++ b/src/main/java/latice/model/Deck.java @@ -9,12 +9,18 @@ public class Deck { this.deckTile = deckTile; } - public void getListTile() { + 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 index f4af62f..36f0e60 100644 --- a/src/main/java/latice/model/Rack.java +++ b/src/main/java/latice/model/Rack.java @@ -5,17 +5,24 @@ import java.util.ArrayList; public class Rack { private ArrayList listRackTile = new ArrayList(); - public Rack(ArrayList deck) { + 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.size()-0+1)+0); - listRackTile.add(deck.get(index)); - System.out.println("l'indice de la tuile ajouté au rack est : " + index + " qui est la tuile " + deck.get(index)); + 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 + } - -//(int)(Math.random()*(max-min+1)+min); \ No newline at end of file