From ggc
|
01 packagepackage is used to name the directory or folder a class is in GBell.LightsOutModel;
02
03 importimport means to make the classes and/or packages available in this program java.util.*;
04 importimport means to make the classes and/or packages available in this program wiki.Wiki;
05 /**
06 * All about my application here.
07 * @authorthis is the Javadoc tag for documenting who created the source code Geremy Bell
08 * originated by Jam Jenkins
09 */
10 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 TextInterface
11 {open braces start code blocks and must be matched with a close brace
12 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)
13 {open braces start code blocks and must be matched with a close brace
14 LightsOutModel model;
15 model=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor LightsOutModel();
16 whilewhile is a looping structure for executing code repeatedly(model.won()==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)
17 {open braces start code blocks and must be matched with a close brace
18 Wiki.out.println("Board:");
19 Wiki.out.println(model);
20 Wiki.out.println("What row would you like to play (0-4)?");
21 Scanner scanner=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Scanner(Wiki.in);
22 String number=this assignment operator makes the left side equal to the right sidescanner.next();
23 intint is the type for whole numbers and it is short for integer row=this assignment operator makes the left side equal to the right side-1;
24 trytry is for executing a code block that may experience exceptions (errors)
25 {open braces start code blocks and must be matched with a close brace
26 row=this assignment operator makes the left side equal to the right sideInteger.parseInt(number);
27 }close braces end code blocks and must match an earlier open brace
28 catchcatch means to handle an exception that may occur(NumberFormatException nfe)
29 {open braces start code blocks and must be matched with a close brace
30 Wiki.out.println("Not a number: "+adds two numbers together or concatenates Strings togethernumber);
31 }close braces end code blocks and must match an earlier open brace
32 Wiki.out.println("What column would you like to play (0-4)?");
33 number=this assignment operator makes the left side equal to the right sidescanner.next();
34 intint is the type for whole numbers and it is short for integer column=this assignment operator makes the left side equal to the right sideInteger.parseInt(number);
35 ifif executes the next statement only if the condition in parenthesis evaluates to true(row>=this evaluates to true if the left side is not less than the right side0 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) row <=this evaluates to true if the left side is not more than the right side4 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) column>=this evaluates to true if the left side is not less than the right side0 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) column<=this evaluates to true if the left side is not more than the right side4)
36 {open braces start code blocks and must be matched with a close brace
37 model.play(row, column);
38 }close braces end code blocks and must match an earlier open brace
39 elseelse is what happens when the if condition is false
40 {open braces start code blocks and must be matched with a close brace
41 ifif executes the next statement only if the condition in parenthesis evaluates to true(row<0)
42 {open braces start code blocks and must be matched with a close brace
43 Wiki.out.println("Row must be 0 to 4 inclusive (not negative).");
44 }close braces end code blocks and must match an earlier open brace
45 ifif executes the next statement only if the condition in parenthesis evaluates to true(column<0)
46 {open braces start code blocks and must be matched with a close brace
47 Wiki.out.println("Column must be 0 to 4 inclusive (not negative).");
48 }close braces end code blocks and must match an earlier open brace
49 ifif executes the next statement only if the condition in parenthesis evaluates to true(row>4)
50 {open braces start code blocks and must be matched with a close brace
51 Wiki.out.println("Row must be 0 to 4 inclusive (no larger than 4).");
52 }close braces end code blocks and must match an earlier open brace
53 ifif executes the next statement only if the condition in parenthesis evaluates to true(column>4)
54 {open braces start code blocks and must be matched with a close brace
55 Wiki.out.println("Column must be 0 to 4 inclusive (no larger than 4).");
56 }close braces end code blocks and must match an earlier open brace
57 }close braces end code blocks and must match an earlier open brace
58 }close braces end code blocks and must match an earlier open brace
59 Wiki.out.println("Congratulations, you won!");
60 }close braces end code blocks and must match an earlier open brace
61 }close braces end code blocks and must match an earlier open brace
|
Compiler Errors:
----------
1. ERROR in GBell/LightsOutModel/LightsOutModel.java (at line 30)
cells[row][col]=!cells[r][c];
^
r cannot be resolved
----------
2. ERROR in GBell/LightsOutModel/LightsOutModel.java (at line 30)
cells[row][col]=!cells[r][c];
^
c cannot be resolved
----------
10 problems (10 errors)
Download/View GBell/LightsOutModel/TextInterface.java