Hey rojroj,
I don't think this is anywhere near as complicated as you require but here is an example I wrote:
import java.math.*;
import java.text.*;
public class Rojroj {
public static String space1 = " ";
public static String space2 = " ";
public static String noSpace = "";
public static String leftWall = "|";
public static String rightWall = "|";
public static String player = "o";
public static int finalScore = 0;
public static double randomDouble;
public static void randomise(){
DecimalFormat df = new DecimalFormat("#.##");
double rd = Math.random();
randomDouble = Double.parseDouble(df.format(rd));
//System.out.println(randomDouble);
if(randomDouble >= 0.75){
move();
}
else{
noMove();
}
}
public static void move(){
finalScore++;
System.out.println(leftWall + space1 + player + space2 + rightWall);
randomise();
}
public static void noMove(){
System.out.println(leftWall + player + space2 + rightWall);
System.out.println(" ");
System.out.println("Game Over! - You cleared " + finalScore + " obsticle(s)");
}
public static void main(String[] args){
System.out.println(leftWall + space1 + player + space2 + rightWall);
randomise();
}
}
Example output:
| o |
| o |
| o |
| o |
|o |
Game Over! - You cleared 3 obsticle(s)