Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Dice Game: Need help finishing

Started by RonanHayes May 5, 2003 at 9:39 AM 0 replies 600+ views
Original Post
RonanHayes
RonanHayes
Hey all Im not a big fan of Java but I was given this to do so I had to. Anyway its nearly finished or so I think anyway, basically all I need to do now is validate and ensure that if the user is outside the top 10 then they dont get to enter into the scoreboard. so I''ve created an if statement within a for loop for (int i=0; i<10 && i< scores.size(); i++) { if(total > ((LeaderBoard)scores.get(i)).getScore()) { enterName(); } else scoreBoard(); } Basically it has database access, to store the scores and well since I dont really know much about vectors, Im pretty stuck, I know the basics any help would be fantastic. full source is located @ http://www.weclome.ie/ronan/DiceGame.zip if you could take a look and let me know what I need to improve I still have to tidy the whole thing up, but this is something that has been bugging me for sometime. this particular snip of code is located in the DiceGame.java in the method actionPerformed. Any help would be great Ronan
garazdawi
garazdawi
The way it is now the player is left to go to the writeName method for each rank which he beat ie if he got in first place he would have to enter his name for 1st,2nd,3rd...10th

To get away from this try this


boolean check=false;
for (int i=0; i<10 && i< scores.size(); i++)
{
if(total > ((LeaderBoard)scores.get(i)).getScore())
{
check=true;
}
}
if (check) {
enterName();
}
else
scoreBoard();

BTW you might want to but a break in the for loop so that the i value is preserved and then send it as a parameter to the entername method...just a little tip to make things easier...or just complicate things


BTW2: I couln''t access the address you gave......
garazdawi - 'I put the laughter back in slaughter'

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.