![]() The problem with the method is that it asks the ball and the players for them to paint themselves. ![]() :)Īt the end of the class there's the paintComponent method that correctly does have the annotation. Remember, bits and bytes aren't expensive to store, you can use as many of them as is required to get clear and self explaining method names. Contrast that with increaseScore(PlayerId.TWO), or perhaps with even renaming the method: increaseScoreForPlayer(PlayerId.TWO). This would also make the increaseScore method more readable, as currently increaseScore(2) looks like you'd increase the score by two points, whereas actually you are increasing the score for player two. Public class PongPanel extends JPanel implements ActionListener, KeyListener next to the class fields, and change the method signatures from something like getPlayer(int playerNo) to getPlayer(PlayerId player). Private final static int WIDTH = 700, HEIGHT = 450 ![]() I have recently written the following Pong game in Java:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |