import java.util.Random;

public class RaceMove
{
    int hare = 1;
    int tortoise = 1;

    public int torMove()
    {
        Random number = new Random();
        int i =  1 + number.nextInt(10);

        switch (i)
        {
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
                tortoise += 3;
                break;
            case 6:
            case 7:
                tortoise -= 6;
                break;
            case 8:
            case 9:
            case 10:
                tortoise += 1;
                break;
        }

        if (tortoise < 1)
            tortoise = 1;
        else if (tortoise > 70)
        {
            tortoise = 70;  
        }
    return tortoise;
    }

    public int hareMove()
    {
        Random number = new Random();
        int i =  1 + number.nextInt(10);

        switch (i)
        {
            case 1:
            case 2:
                break;
            case 3:
            case 4:
                hare += 9;
                break;
            case 5:
                hare -= 12;
                break;
            case 6:
            case 7:
            case 8:
                hare += 1;
                break;
            case 9:
            case 10:
                hare -= 2;
                break;
        }

        if (hare < 1)
            hare = 1;
        else if (hare > 70)
        {
            hare = 70;
        }   
    return hare;
    }
}



public class Race
{
    public static void main(String[] args)
    {
        RaceMove move = new RaceMove();

        System.out.println("BANG !!!!!");
        System.out.println("AND THEY'RE OFF !!!!!");

        while (move.torMove() < 70 && move.hareMove() < 70) 
        {
            //System.out.println("Tortoise: " + move.torMove());
            //System.out.println("Hare: " + move.hareMove());
        }

        if (move.torMove() > move.hareMove())
            System.out.println("TORTOISE WINS !!! YAY !!! ");

        else if (move.torMove() < move.hareMove())
            System.out.println("Hare wins. Yuch." );

        else 
            System.out.println("It's a tie. ");
    }
}

I'm looking for help with my programming assignment. I have to create a tortoise and hare race and print "H" and "T" as they move on the screen. This is the output that i need to achieve. Here is the link of the output Click Here

And what is your actual question?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.