STEP 1 : ADD Deck and Rack classes with UPDATE LaticeApplicationConsole

master
mathi 2022-04-23 16:05:32 +02:00 committed by cemal
parent 431e9759e9
commit 16db96f887
3 changed files with 28 additions and 12 deletions

View File

@ -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();

View File

@ -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<Tile> getListTile() {
return this.deckTile;
}
}

View File

@ -5,17 +5,24 @@ import java.util.ArrayList;
public class Rack {
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++) {
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);