I'm having problems compiling my program, I was wondering if someone could tell me where I went wrong and how to fix it. I would be deeply apreaciative of your help!!!! :)
import java.util.Random;
import java.io.Console;
class project2_0
{
int[] race = new int[70];
int tortoise;
int hare;
Random randomnumbers = new Random();
boolean again = true;
public void StartRace()
{
tortoise = 1;
hare = 1;
Console.WriteLine("ON YOUR MARK, GET SET.... BANG!!!");
Console.WriteLine("AND THEY'RE OFF!!!!");
while (tortoise < 70 && hare < 70)
{
MoveHare();
MoveTortoise();
DisplayCurrentLocation();
string request;
} //end while
if
(tortoise > hare)
{
Console.WriteLine("\n TORTOISE WINS!! YAY!!!!!");
}
else if
(hare > tortoise)
{
Console.WriteLine("\n HARE WINS!!!");
}
else if
(hare == tortoise)
{
Console.WriteLine ("TIE!!!");
}
}
public void MoveTortoise()
{
//to randomize move
int percent = randomnumbers.Next(1, 11);
//now determine moves based on graph
//fast plod
if (percent >= 1 && percent <= 5)
tortoise += 3;
//slip
else if (percent == 6 || percent == 7)
tortoise -= 6;
//slow plod
else
++tortoise;
// protect from going past start
if (tortoise < 1)
tortoise = 1;
// to make sure game ends
else if (tortoise > 70)
tortoise = 70;
}// end tortoise
public void MoveHare()
{
// randomize move
int percent = randomnumbers.Next(1, 11);
// determine moves by graph
//big hop
if (percent == 3 || percent == 4)
hare += 9;
//big slip
else if (percent == 5)
hare -= 12;
// small hop
else if (percent >= 6 && percent <= 8)
++hare;
// )small slip
else if (percent > 8)
hare -= 2;
//ensure hare doesn't go past start
if (hare < 1)
hare = 1;
// ensure hare doesnt go past end
else if (hare > 70)
hare = 70;
} // end movehare
public void DisplayCurrentLocation()
{
//this is the location of each on the array
for (int count = 1; count <= 70; count++)
// same spot
if (count ==tortoise && count ==hare)
{
Console.WriteLine ("OUCH");
}
else if (count == hare)
{
Console.WriteLine ("H");
}
else if (count == tortoise)
{
Console.WriteLine("T");
}
else
Console.WriteLine();
}
public class RaceTest
{
static void main( String[] args )
{
boolean again = true;
Race Application = new Race();
string request;
do
{
Application.StartRace();
Console.WriteLine("");
Console.WriteLine("Do you want to Play again y/n");
request = Console.ReadLine();
if (request == "Y" || request == "y")
{
again = true;
}
else
{
again = false;
}
}
while (again == true);
Console.Writeline ("Thank you for Playing");
}
}
}