I was wondering if there is a way to randomly print strings. I have this code where I have bushes represented by "( )" and rocks represented by ".". Now I want these to print out according to a random int in a different class. However they just print in one straight line. I was wondering if there is an easy way to make them all randomly generate. So instead of looking like this ( ) ( ) ( ) ( ).. they look more like this ( ) . ( ) . ( ) ( ). Thanks a lot for whoever takes the time to respond.
With a final output of
^
/|\
. ( ) /|\ . ( ) ( )
Program:
import java.util.ArrayList;
public class ForestRandomizer {
public static String forestGen()
{
String bush = "( )";
ArrayList<String> bushes = new ArrayList<String>();
for(int n = 0; Walking.bushesInArea > n; n++)
{
bushes.add(bush);
}
String rock = ".";
ArrayList<String> rocks = new ArrayList<String>();
for(int n = 0; Walking.rocksInArea > n; n++)
{
rocks.add(rock);
}
System.out.println();
System.out.println();
System.out.println();
for(int i = 0; i < bushes.size(); i++)
{
System.out.print(bushes.get(i) + " ");
}
for(int i = 0; i < rocks.size(); i++)
{
System.out.print(rocks.get(i) + " ");
}
System.out.println();
return null;
}
}