![]() |
help filling array randomly, in a way
I have a little problem with an algorthm. I have to make the game Concentration. It's a game in which tiles are placed face-down in rows on a "concentraction board". Each tile contains a string. For each tile, there is exactly one other tile like that, which is also faced down.
The problem I am having is filling the board up randomly with having only 2 of the each tile in the board. I know there has to be a simple way to do it but my mind justs goes blank. Any help fellows? :
public class Tile Here is the code for the FooList A FooList is a class that defines a list of strings and a string length. All strings in a FooList have the same length. :
import java.util.ArrayList;:
import java.util.ArrayList; |
add every string twice to the list?
|
Quote:
|
I meant: maybe you should just add every string twice to the foolist (in the method addFoo). Then you randomly take the strings out until the list is empty.
|
Divide your tiles into two identical sets. Place each set randomly.
EDIT: Woops, missed the above post. Essentially the same thing. |
| All times are GMT -5. The time now is 1:01 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC