This site requires JavaScript, please enable it in your browser!
Greenfoot back
tylers
tylers wrote ...

2012/12/3

making your own getTop()

tylers tylers

2012/12/3

#
ive got two scoreboards on this game: http://www.greenfoot.org/scenarios/5114 one of the maps saves the score in the score column using userinfo and the other map saves it in another column. i use getTop() to get the score board in the right order for the first map but on the second map im not sure what to use. so how can i order it for the second map.
danpost danpost

2012/12/3

#
What is map2 trying to display, exactly? Like, map1 is based on the number of levels completed (or started).
tylers tylers

2012/12/3

#
yes. i would like a method like getTop() but the method needs to work with the other colloums not just the score colloum
danpost danpost

2012/12/3

#
You may have to modify the ScoreBoard class to be able to produce two different results. However, to do a method like getTop on another column will require you to read in ALL UserInfo objects for the scenario; and that will require some trickery. Then start with the first five and sort them. Next, for the remaining ones, compare to the fifth one. If greater than replace the fifth one and as long as it is better than the one before it, swap it up in place to get the top five sorted again. The code used to acquire all UserInfo objects for the scenario is listed here.
danpost danpost

2012/12/3

#
Instead of modifying the ScoreBoard class, it might be better to create a ScoreBoard2 class and copy/paste the code into it from ScoreBoard and change all 'ScoreBoard' to 'ScoreBoard2'. Then modify that code to produce your different list and display it.
tylers tylers

2012/12/3

#
sorry I don't really get it. :( do you have another code example?
You need to login to post a reply.