STEP 1 : ADD Deck and Rack classes with UPDATE LaticeApplicationConsole
parent
431e9759e9
commit
16db96f887
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import latice.model.Color;
|
import latice.model.Color;
|
||||||
import latice.model.Deck;
|
import latice.model.Deck;
|
||||||
|
import latice.model.Rack;
|
||||||
import latice.model.Shape;
|
import latice.model.Shape;
|
||||||
import latice.model.Tile;
|
import latice.model.Tile;
|
||||||
|
|
||||||
|
@ -18,18 +19,20 @@ public class LaticeApplicationConsole {
|
||||||
for (Color color : Color.values()) {
|
for (Color color : Color.values()) {
|
||||||
for (Shape shape : Shape.values()) {
|
for (Shape shape : Shape.values()) {
|
||||||
Tile tile = new Tile(color, shape);
|
Tile tile = new Tile(color, shape);
|
||||||
System.out.println("tuile : couleur = " + tile.getColor() + " forme = " + tile.getShape());
|
|
||||||
listOfTile.add(tile);
|
listOfTile.add(tile);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("-----------------");
|
||||||
System.out.println("Notre Deck :");
|
System.out.println("Notre Deck :");
|
||||||
Deck deck = new Deck(listOfTile);
|
Deck deck = new Deck(listOfTile);
|
||||||
deck.getListTile();
|
deck.displayListTile();
|
||||||
System.out.println("-----------------");
|
System.out.println("-----------------");
|
||||||
|
Rack rack = new Rack(deck);
|
||||||
|
System.out.println("-----------------");
|
||||||
|
deck.displayListTile();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,18 @@ public class Deck {
|
||||||
this.deckTile = deckTile;
|
this.deckTile = deckTile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getListTile() {
|
public void displayListTile() {
|
||||||
for (Tile tile : deckTile) {
|
for (Tile tile : deckTile) {
|
||||||
System.out.println("tuile : couleur = " + tile.getColor() + " forme = " + tile.getShape());
|
System.out.println("tuile : couleur = " + tile.getColor() + " forme = " + tile.getShape());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<Tile> getListTile() {
|
||||||
|
return this.deckTile;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,17 +5,24 @@ import java.util.ArrayList;
|
||||||
public class Rack {
|
public class Rack {
|
||||||
private ArrayList<Tile> listRackTile = new ArrayList<Tile>();
|
private ArrayList<Tile> listRackTile = new ArrayList<Tile>();
|
||||||
|
|
||||||
public Rack(ArrayList<Tile> deck) {
|
public Rack(Deck deck) {
|
||||||
|
System.out.println("Il y a dans le rack : " + listRackTile.size() + " valeurs");
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
int index = (int)(Math.random()*(deck.size()-0+1)+0);
|
int index = (int)(Math.random()*((deck.getListTile()).size()-0+1)+0); //(int)(Math.random()*(max-min+1)+min);
|
||||||
listRackTile.add(deck.get(index));
|
listRackTile.add((deck.getListTile()).get(index));
|
||||||
System.out.println("l'indice de la tuile ajouté au rack est : " + index + " qui est la tuile " + deck.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);
|
|
Loading…
Reference in New Issue