Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+6 votes

I am doing the high scores table, does anyone know how to implements it to the main class ??

asked in CSC305 Fall 2019 by (1 point)

1 Answer

+3 votes

Presumably a feature like high scores should be implemented in its own class, rather than included in the "main" class.

Good object-oriented design involves splitting up the responsibilities among different classes, with each class having responsibilities that match its name. Perhaps you need a HighScoresTable class, and should think about which methods it needs -- perhaps something like this:

  • List getRankedListOfNames()
  • List getRankedListOfScores()
  • void addNewScore(String name, int score)

and naturally, you'd need some private fields to store the high scores data.

answered by (508 points)