Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

HighScore Table

Hey people.

At the moment im trying to make a yatzy (Yes it's spelled like that in Sweden) game, so far it goes well with the total count and bouns points. it also shows who's the winner and the point of the winner.


The Problem comes to me when trying to show the highscore. Right now i dont have a save for it but the real problem is that it doesnt update with the new highscore that is made by the player.


Im using YatzyVann as a score and YatzyVinnare as the name om the player that won the game.

the only result that is showing is 1-10 with 0 as score, can someone help me or have i done it all wrong?

This is the code that i have done for that part.

           for (int i = 0; i > 9; i++)

           {

               if (YatzyHigh[0] < Convert.ToInt32(YatzyVann))

               {

                   YatzyHigh[0] = Convert.ToInt32(YatzyVann);

                   YatzyHighName[0] = YatzyVinnare;

                   for (int x = i + 1; x < YatzyHigh.Length -1; x++)

                   {

                       YatzyHigh[i + 2] = YatzyHigh[i + 1];

                       YatzyHighName[i + 2] = YatzyHighName[i + 1];

                   }

               }

                   if (YatzyHigh[i] > Convert.ToInt32(YatzyVann) && YatzyHigh[i+1] < Convert.ToInt32(YatzyVann))

                   {


                       //Förflyttar de med lägre poäng till en lägre ställningi highscorelistan

                           YatzyHigh[i+1] = Convert.ToInt32(YatzyVann);

                         YatzyHighName[i+1] = YatzyVinnare;

                       for (int x = i + 1; x < YatzyHigh.Length-1; x++)

                       {

                         YatzyHigh[i + 2] = YatzyHigh[i + 1];

                         YatzyHighName[i + 2] = YatzyHighName[i + 1];

                       }

                   }

           }

           Console.WriteLine("Top 10 poäng");

           for (int i = 0; i < YatzyHigh.Length; i++)

           {

               if (i == YatzyHigh.Length-1)

               {

                   Console.WriteLine(i + 1 + " " + YatzyHigh[i] + " " + YatzyHighName[i]);

                   break;

               }

               Console.WriteLine(i+1 + "  " + YatzyHigh[i] + " " + YatzyHighName[i]);

           }

Best Answer

  • HerrNegnarHerrNegnar Member
    Accepted Answer

    Sorry people about this post, i saw my problem finally, in the first part of the loop "for (int i = 0; i > 9; i++)".

    offcourse i cant start by being bigger than 9 it starts at 0.


    have a good one out there.

Sign In or Register to comment.