Table Of Contents

 

1. Introduction................................................................................................................... 3

1.1. Project Description.................................................................................................. 3

1.2. The Scrabble Game................................................................................................. 3

1.2.1. The Desk Version.............................................................................................. 3

1.2.2. The ‘Scrabble in Java’ Version............................................................................ 4

2. The ‘Scrabble in Java’ Application.................................................................................... 5

2.1. Program Structure................................................................................................... 5

2.2. Main Algorithms...................................................................................................... 9

2.2.1. Animator........................................................................................................... 9

2.2.2. Chat................................................................................................................. 9

2.2.3. Dictionary......................................................................................................... 9

2.2.4. Drag & Drop.................................................................................................... 10

2.2.5. Help Files....................................................................................................... 11

2.2.6. Image Buttons................................................................................................. 11

2.2.7. Loading Images............................................................................................... 12

2.2.8. Loading & Saving a game................................................................................. 12

2.2.9. Receptionist.................................................................................................... 13

2.2.10. Scrollbars...................................................................................................... 14

2.2.11. Timer............................................................................................................ 14

2.3. The Communication Protocol.................................................................................. 16

2.3.1. The sockets.................................................................................................... 16

2.3.2. Sending messages.......................................................................................... 16

2.3.3. Handling disconnection.................................................................................... 16

2.3.4. When game data changes................................................................................ 16

2.3.5. When a new turn data need to be sent............................................................... 16

2.3.6. Errors during data traffic................................................................................... 17

2.4. Data Structures..................................................................................................... 18

2.5. Classes Overview................................................................................................... 19

2.5.1. AboutDialog.................................................................................................... 19

2.5.2. Board............................................................................................................. 19

2.5.3. ButtonDescription............................................................................................ 19

2.5.4. C.................................................................................................................... 20

2.5.5. ChatArea........................................................................................................ 20

2.5.6. CheckDictionary.............................................................................................. 21

2.5.7. CheckWords................................................................................................... 21

2.5.8. ChooseDialog.................................................................................................. 21

2.5.9. Client.............................................................................................................. 22

2.5.10. ClientData..................................................................................................... 22

2.5.11. ClientHandler................................................................................................. 23

2.5.12. ClientOrServer............................................................................................... 23

2.5.13. ConnectDialog............................................................................................... 24

2.5.14. ImageButton.................................................................................................. 24

2.5.15. Mail.............................................................................................................. 25

2.5.16. MultiServer.................................................................................................... 25

2.5.17. PlayerName.................................................................................................. 26

2.5.18. ProgressBarTimer.......................................................................................... 26

2.5.19. PropertiesDialog............................................................................................ 27

2.5.20. QuitDialog..................................................................................................... 27

2.5.21. Receptionist.................................................................................................. 28

2.5.22. Score............................................................................................................ 28

2.5.23. ScoreOfPlayers............................................................................................. 28

2.5.24. ScorePanel................................................................................................... 29

2.5.25. Scrabble....................................................................................................... 29

2.5.26. ScrabbleBoard............................................................................................... 30

2.5.27. ScrollingPanel............................................................................................... 30

2.5.28. ServerData.................................................................................................... 31

2.5.29. Spinner......................................................................................................... 32

2.5.30. StatusBarPanel............................................................................................. 32

2.5.31. StatusField.................................................................................................... 33

2.5.32. Timer............................................................................................................ 33

2.5.33. ToolBarPanel................................................................................................. 33

2.5.34. TurnTimer...................................................................................................... 34

2.5.35. Symantec classes......................................................................................... 34

3. User’s Manual............................................................................................................. 35

3.1. Graphical User Interface (GUI)................................................................................. 35

3.1.1. Toolbar........................................................................................................... 35

3.1.2. Status bar....................................................................................................... 35

3.1.3. Chat area........................................................................................................ 35

3.1.4. Score of Players.............................................................................................. 35

3.1.5. Score details................................................................................................... 35

3.1.6. Play Board...................................................................................................... 36

3.2. The Menus............................................................................................................ 37

3.2.1. File................................................................................................................. 37

3.2.2. Game............................................................................................................. 38

3.2.3. Connect.......................................................................................................... 38

3.2.4. Settings.......................................................................................................... 39

3.2.5. Help............................................................................................................... 40

3.3. Playing ‘Scrabble in Java’ – typical scenario............................................................. 41

4. Summary and Conclusions........................................................................................... 42

4.1. Software Limitations............................................................................................... 42

4.1.1. The difficulties using the java.net.ServerSocket.................................................. 42

4.1.2. Dialog windows................................................................................................ 42

4.1.3. Drag & Drop using java.awt.Window.................................................................. 42

4.1.4. Garbage Collector............................................................................................ 43

4.1.5. Compatibility................................................................................................... 43

4.1.6. Portability....................................................................................................... 43

4.2. Conclusions.......................................................................................................... 44

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1. Introduction

1.1. Project Description

The goal of the project was to create a network computer game, based on the widely known Scrabble game, using the Java programming language. The game can be played simultaneously by up to 4 players via a network.

 

Special features of the application:

 

·       Improved Java GUI that includes toolbar, status bar and scrolling panels (application can be resized to any size).

·       16 bit color graphics.

·       Communication between players.

·       Possibility to ‘Kick’ a player out of the game.

·       Word checking with or without a dictionary (the server checks the words in a proper dialog window).

·       The maximum number of players can be changed before compiling the program (the default is 4).

 

The application was developed using Symantec Visual Cafe and Sun’s JDK1.0.2 under the Microsoft NT/95 operating system.

1.2. The Scrabble Game

1.2.1. The Desk Version

Scrabble is a widely known desk game, which is played on a 15x15 grid board, by up to 4 players. The game pieces are letter tiles, with a different score for each letter.  Each player gets 7 letters, that should be placed on the board in order to form words. In each turn a player can form several words by adding letters to the board. The player gets a score for each valid word that he places on the board. A word score depends on the score of its letters and on their location on the board. There are cells on the board, which increase the score of letters (x2 or x3), or the score of the whole word (x2 or x3).

 

Major rules of the game:

 

1.       First word must cover the center tile.

2.       Each word must have at least one common letter with the previously placed words.

3.       Same words may be placed many times on the board.

4.       All words formed by new letters have to be approved by the dictionary or the server player.

5.       The words are read from left to right, and from top to bottom.

6.       If a word is placed on some special squares, the effects are commutative with each other (for instance, if a word is placed on a double word and a triple word, then the score is *6 for that word).

7.       If a player passes his turn, he gets 7 new letters.

8.       If a player didn’t finish he’s turn before the time limit, he gets no new letters, and the turn is passed to the next player.

1.2.2. The ‘Scrabble in Java’ Version

The ‘Scrabble in Java’ application is based on the desk version of the game and basically implements the same game rules.  

The game can be played by up to 4 players simultaneously, playing against each other.  In case of a single player, he or she plays against the speller only - there is no computer player.  Each player starts the Scrabble game on his/her local computer, and is connected via a network.

 

Words that are placed on the board can be checked in 2 ways:

1.       Internal Speller (based on the Oxford dictionary).

2.       The ‘Server’ player.

Words are checked from top to bottom and from left to right.

 

The maximum number of players can be changed before compiling the program by changing the variable MAX_NUM_OF_PLAYERS in C.java from 4 to the desired number of players.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2. The ‘Scrabble in Java’ Application

2.1. Program Structure

The following figures show the different scrabble classes.