jeudi 30 avril 2015

How to randomly fill fixed amount of columns in 2d array with a value in java?

Wordy question, let me give an example

The program that I am creating makes a 2D world using a 2D array whose sized is based on user input. In this example the world is a 4 X 10 world

----------
----------
----------
----------

How would I put 3 Xs in random positions along the bottom Row?

i.e.

----------
----------
----------
--x-x---x-

but making sure that it is random so that they don't appear in the same row if I run the method again?




Aucun commentaire:

Enregistrer un commentaire