aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-02-11 21:40:11 +0100
committerPacien TRAN-GIRARD2014-02-11 21:49:14 +0100
commitdbcd6b62048f65886544ab8771c2cf276628db59 (patch)
tree35bbce42b4412ed2aa911890e87fceb2bf5df560 /src
parent02ff696e341199e97d79442e3fd86a2baea1ff3c (diff)
downloadesieequest-dbcd6b62048f65886544ab8771c2cf276628db59.tar.gz
Clean code (auto indent, update author and version)
Diffstat (limited to 'src')
-rw-r--r--src/esieequest/Command.java57
-rw-r--r--src/esieequest/CommandWords.java57
-rw-r--r--src/esieequest/Game.java362
-rwxr-xr-xsrc/esieequest/Main.java21
-rw-r--r--src/esieequest/Parser.java108
-rw-r--r--src/esieequest/Room.java75
6 files changed, 315 insertions, 365 deletions
diff --git a/src/esieequest/Command.java b/src/esieequest/Command.java
index 4ebc02a..f6afdea 100644
--- a/src/esieequest/Command.java
+++ b/src/esieequest/Command.java
@@ -4,39 +4,32 @@ package esieequest;
4 * Représente une commande tapée au clavier qui provoque une action dans le jeu. 4 * Représente une commande tapée au clavier qui provoque une action dans le jeu.
5 * 5 *
6 * @author Pacien TRAN-GIRARD 6 * @author Pacien TRAN-GIRARD
7 * @version Février 2013 7 * @author Benoit LUBRANO DI SBARAGLIONE
8 *
9 * @version February 2014
8 */ 10 */
9public class Command 11public class Command {
10{ 12 private String aCommandWord;
11 private String aCommandWord; 13 private String aSecondWord;
12 private String aSecondWord; 14
15 public Command(final String pCommandWord, final String pSecondWord) {
16 this.aCommandWord = pCommandWord;
17 this.aSecondWord = pSecondWord;
18 }
19
20 public String getCommandWord() {
21 return this.aCommandWord;
22 }
23
24 public String getSecondWord() {
25 return this.aSecondWord;
26 }
13 27
14 /** 28 public boolean isUnknown() {
15 * Constructeur 29 return this.aCommandWord == null;
16 */ 30 }
17 public Command(final String pCommandWord, final String pSecondWord)
18 {
19 this.aCommandWord = pCommandWord;
20 this.aSecondWord = pSecondWord;
21 }
22
23 public String getCommandWord()
24 {
25 return this.aCommandWord;
26 }
27
28 public String getSecondWord()
29 {
30 return this.aSecondWord;
31 }
32 31
33 public boolean isUnknown() 32 public boolean hasSecondWord() {
34 { 33 return this.aSecondWord != null;
35 return this.aCommandWord == null; 34 }
36 }
37
38 public boolean hasSecondWord()
39 {
40 return this.aSecondWord != null;
41 }
42} 35}
diff --git a/src/esieequest/CommandWords.java b/src/esieequest/CommandWords.java
index d2dd2f3..3a77015 100644
--- a/src/esieequest/CommandWords.java
+++ b/src/esieequest/CommandWords.java
@@ -1,42 +1,37 @@
1package esieequest; 1package esieequest;
2 2
3/** 3/**
4 * This class is part of the "World of Zuul" application. 4 * This class is part of the "World of Zuul" application. "World of Zuul" is a
5 * "World of Zuul" is a very simple, text based adventure game. 5 * very simple, text based adventure game.
6 * 6 *
7 * This class holds an enumeration table of all command words known to the game. 7 * This class holds an enumeration table of all command words known to the game.
8 * It is used to recognise commands as they are typed in. 8 * It is used to recognise commands as they are typed in.
9 * 9 *
10 * @author Michael Kolling and David J. Barnes + D.Bureau 10 * @author Michael Kolling and David J. Barnes + D.Bureau
11 * @version 2008.03.30 + 2013.09.15 11 * @version 2008.03.30 + 2013.09.15
12 */ 12 */
13public class CommandWords 13public class CommandWords {
14{ 14 // a constant array that holds all valid command words
15 // a constant array that holds all valid command words 15 private static final String[] sValidCommands = { "go", "quit", "help" };
16 private static final String[] sValidCommands = {
17 "go", "quit", "help"
18 };
19 16
20 /** 17 /**
21 * Constructor - initialise the command words. 18 * Constructor - initialise the command words.
22 */ 19 */
23 public CommandWords() 20 public CommandWords() {
24 { 21 // nothing to do at the moment...
25 // nothing to do at the moment... 22 } // CommandWords()
26 } // CommandWords()
27 23
28 /** 24 /**
29 * Check whether a given String is a valid command word. 25 * Check whether a given String is a valid command word.
30 * @return true if a given string is a valid command, 26 *
31 * false if it isn't. 27 * @return true if a given string is a valid command, false if it isn't.
32 */ 28 */
33 public boolean isCommand( final String pString ) 29 public boolean isCommand(final String pString) {
34 { 30 for (int i = 0; i < sValidCommands.length; i++) {
35 for ( int i=0; i<sValidCommands.length; i++ ) { 31 if (sValidCommands[i].equals(pString))
36 if ( sValidCommands[i].equals( pString ) ) 32 return true;
37 return true; 33 } // for
38 } // for 34 // if we get here, the string was not found in the commands
39 // if we get here, the string was not found in the commands 35 return false;
40 return false; 36 } // isCommand()
41 } // isCommand()
42} // CommandWords 37} // CommandWords
diff --git a/src/esieequest/Game.java b/src/esieequest/Game.java
index 263244b..147efc5 100644
--- a/src/esieequest/Game.java
+++ b/src/esieequest/Game.java
@@ -3,195 +3,177 @@ package esieequest;
3/** 3/**
4 * Moteur du jeu. 4 * Moteur du jeu.
5 * 5 *
6 * @author Pacien TRAN-GIRARD and Benoit LUBRANO DI SBARAGLIONE 6 * @author Pacien TRAN-GIRARD
7 * @version Février 2014 7 * @author Benoit LUBRANO DI SBARAGLIONE
8 *
9 * @version February 2014
8 */ 10 */
9public class Game 11public class Game {
10{ 12 private Room aCurrentRoom;
11 private Room aCurrentRoom; 13 private Parser aParser;
12 private Parser aParser; 14
13 15 public Game() {
14 /** 16 this.createRooms();
15 * Constructor for objects of class Game 17 this.printWelcome();
16 */ 18 this.printRoomInfo();
17 public Game() 19 this.play();
18 { 20 }
19 this.createRooms(); 21
20 this.printWelcome(); 22 private void play() {
21 this.printRoomInfo(); 23 aParser = new Parser();
22 this.play(); 24 boolean vFinished = false;
23 } 25 while (!vFinished) {
24 26 Command vCommand = this.aParser.getCommand();
25 private void play() 27 vFinished = this.processCommand(vCommand);
26 { 28 }
27 aParser = new Parser(); 29
28 boolean vFinished = false; 30 System.out.println("Thank you for playing. Good bye.");
29 while (!vFinished) { 31 }
30 Command vCommand = this.aParser.getCommand(); 32
31 vFinished = this.processCommand(vCommand); 33 private void createRooms() {
32 } 34 // cr�ation des lieux
33 35 Room vAmphitheaterSeat = new Room("in the amphitheater");
34 System.out.println("Thank you for playing. Good bye."); 36 Room vAmphitheaterStage = new Room("on the amphitheater stage");
35 } 37 Room vAmphitheaterEntrance = new Room("at the amphitheater entrance");
36 38 Room vAmphitheaterFront = new Room("in front of the amphitheater");
37 private void createRooms() 39 Room vCafeteria = new Room("in the cafeteria");
38 { 40 Room vCafeteriaFront = new Room("in front of the cafeteria");
39 // création des lieux 41 Room vStudentsUnionFront = new Room("in front of the Students' Union");
40 42 Room vStudentsUnion = new Room("in the Students' Union HQ");
41 Room vAmphitheaterSeat = new Room("in the amphitheater"); 43 Room vStreetEsieespace = new Room("in front of the ESIEEspace HQ");
42 Room vAmphitheaterStage = new Room("on the amphitheater stage"); 44 Room vEsieespaceEntrance = new Room("at the ESIEEspace HQ entrance");
43 Room vAmphitheaterEntrance = new Room("at the amphitheater entrance"); 45 Room vEsieespace = new Room("in the ESIEEspace HQ");
44 Room vAmphitheaterFront = new Room("in front of the amphitheater"); 46 Room vReception = new Room("at the Reception");
45 Room vCafeteria = new Room("in the cafeteria"); 47 Room vEntranceStairs = new Room("at the entrance stairs");
46 Room vCafeteriaFront = new Room("in front of the cafeteria"); 48 Room vRoundabout = new Room("at the roundabout");
47 Room vStudentsUnionFront = new Room("in front of the Students' Union"); 49 Room vWingFront = new Room("in font of wing 3");
48 Room vStudentsUnion = new Room("in the Students' Union HQ"); 50 Room vCorridorOne = new Room("Corridor 3 main floor");
49 Room vStreetEsieespace = new Room("in front of the ESIEEspace HQ"); 51 Room vStairsOne = new Room("in the stairwell at floor 1");
50 Room vEsieespaceEntrance = new Room("at the ESIEEspace HQ entrance"); 52 Room vStairsTwo = new Room("in the stairwell at floor 2");
51 Room vEsieespace = new Room("in the ESIEEspace HQ"); 53 Room vCorridorTwo = new Room("Corridor 3 floor 2");
52 Room vReception = new Room("at the Reception"); 54 Room vWcOne = new Room("in the WC at floor 1");
53 Room vEntranceStairs = new Room("at the entrance stairs"); 55 Room vWcTwo = new Room("in the WC at floor 2");
54 Room vRoundabout = new Room("at the roundabout"); 56 Room vCorridorTwoOffice = new Room("in front of the office at floor 2");
55 Room vWingFront = new Room("in font of wing 3"); 57 Room vOffice = new Room("in the office number 3254");
56 Room vCorridorOne = new Room("Corridor 3 main floor"); 58
57 Room vStairsOne = new Room("in the stairwell at floor 1"); 59 // positionnement des sorties (N,S,E,W)
58 Room vStairsTwo = new Room("in the stairwell at floor 2"); 60 vAmphitheaterSeat.setExits(vAmphitheaterFront, vAmphitheaterFront, null, null);
59 Room vCorridorTwo = new Room("Corridor 3 floor 2"); 61 vAmphitheaterStage.setExits(null, null, vAmphitheaterEntrance, vCafeteria);
60 Room vWcOne = new Room("in the WC at floor 1"); 62 vAmphitheaterEntrance.setExits(vAmphitheaterFront, null, null, vAmphitheaterStage);
61 Room vWcTwo = new Room("in the WC at floor 2");