Lg Long wrote:The story of the winner() method tells if the player wins or not. One responsibility
Lg Long wrote:also I need to take one instance of server and receiver out, else I get the java.lang.ArrayIndexOutOfBoundsException: 4
you're not treating a point value of 4 as a special case.
I'll try one more time to help you organise your thoughts. You need to implement MVC and you've actually started down a good path with that. You already have code for a Controller, that's the game loop that you kind of patterned after an example I gave. Here's a breakdown of responsibilities of different classes that would make up MVC:
View (GameView class)
1. Displays menu
2. Gets input from user
3. Displays status of the game (as provided by the model, through the controller)
Controller (GameController class)
1. Tells the View to display menu
2. Tells the View to get user input (the action)
3. Dispatches user input to appropriate actions
4. Calls appropriate methods in the model to carry out actions requested
5. Passes results of the action performed back to the view for display, if any.
Model (Game class)
1. Keep track of the state of the game - keeps score and determines if game is over
2. Provide methods to change the state of the game - serverWinsPoint(), receiverWinsPoint()
3. Provide method to report the state of the game (getScore(), hasWinner())
That's it! With the four menu options you're supposed to provide to the user (1-Award server a point, 2-Award receiver a point, 3-Show score, 4-Exit) you have everything in the above description to implement a program that does all that.
Lg Long wrote:So, i have my model solved. Can I get some help with the controller, please?
I don't have a picture of what should look like in this example.
I could use some code for starters. Maybe empty methods?