class Race
    {
        int[] race = new int[70];
        int tortoise;
        int hare;
        Random randomnumbers = new Random();
        bool 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)
        {


            Race Application = new Race();
            string request;

            do
         {
            Application.StartRace();


            Console.WriteLine ("");
            Console.WriteLine("Do you want to Play again y/n");
            request = Console.ReadKey();

            if (request == "Y" || request == "y")
            {
                again = true;
            }
            else
            {
                again = false;
            }

         }
        while (again == true);
            Console.Writeline ("Thank you for Playing");



        }
        }

I am looking for help with a school programming assignment. This is my first programming class and I'm a little lost as to what I am doing wrong. I have to create a simple tortoise and the hare race and I need to show them "T" and "H" as they go across the screen and offer the player to play again. I'm having some trouble with both of these. can anyone help? This is what I have so far??

Issues I've found without running the code (not giving the direct fixes immediately as this is homework)
- Line 158, Console.ReadKey() does not directly return/convert into a string.
- Lines 162 166 and 170, the variable again is declared in the Race class and thus is not accessible to the RaceTest class without the variable being public / exposed through a public property.
- Line 138, you do not close the method, nor the entire Race class
- Line 49, you do not close the method.

Now run the code.
It seems to run fine, however I had to put the line Thread.Sleep(1000); on line 27 to be able to see anything actually happen. You may wish to consider presenting the race horizontally instead of vertically

Thank you! that helped! this is only my third assignment, so I'm still learning!

No worries, we all started somewhere :)

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.