From ggc
|
01 /**
02 * All about my application here.
03 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
04 */
05 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects PollingGuessingGame
06 {open braces start code blocks and must be matched with a close brace
07 privateprivate is used to restrict access to the current class only Guess guess;
08 privateprivate is used to restrict access to the current class only ConsoleEngine engine;
09
10 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
11 {open braces start code blocks and must be matched with a close brace
12 guess=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Guess();
13 engine=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ConsoleEngine();
14 }close braces end code blocks and must match an earlier open brace
15
16 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advanceFrame(doubledouble is the type for numbers that can contain decimal fractions timepassed)
17 {open braces start code blocks and must be matched with a close brace
18 ifif executes the next statement only if the condition in parenthesis evaluates to true(guess.gameIsOver()==this is the comparison operator which evaluates to true if both sides are the samefalsefalse is a value for the boolean type and means not true)
19 {open braces start code blocks and must be matched with a close brace
20 engine.giveOutput(guess.getHint());
21 String input=this assignment operator makes the left side equal to the right sideengine.getInput();
22 intint is the type for whole numbers and it is short for integer num=this assignment operator makes the left side equal to the right sideInteger.parseInt(input);
23 guess.setGuess(num);
24 }close braces end code blocks and must match an earlier open brace
25 }close braces end code blocks and must match an earlier open brace
26
27 publicpublic is used to indicate unrestricted access (any other class can have access) staticstatic means that an instance is not required for access (class level access) voidvoid means the method does not return a value mainThe main method is the place where applications begin executing.(String[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays args)
28 {open braces start code blocks and must be matched with a close brace
29 PollingGuessingGame game=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PollingGuessingGame();
30 game.startGame();
31 whilewhile is a looping structure for executing code repeatedly(truetrue is the boolean value that is the opposite of false)
32 game.advanceFrame(1.0/25.0);
33 }close braces end code blocks and must match an earlier open brace
34 }close braces end code blocks and must match an earlier open brace
|
Download/View PollingGuessingGame.java