|
01 packagepackage is used to name the directory or folder a class is in JacobOlson.Interface;
02
03 importimport means to make the classes and/or packages available in this program wiki.Wiki;
04 /**
05 * All about my classclass is a group of fields and methods used for making objects here.
06 * @authorthis is the Javadoc tag for documenting who created the source code Jolson
07 */
08 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 LightsOutModel
09
10 {open braces start code blocks and must be matched with a close brace
11 privateprivate is used to restrict access to the current class only booleanboolean is a type that is either true or false[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[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 cells;
12
13 /**
14 * Initializes all of the lights to on.
15 */
16
17 publicpublic is used to indicate unrestricted access (any other class can have access) LightsOutModel()
18 {open braces start code blocks and must be matched with a close brace
19 cells=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor booleanboolean is a type that is either true or false[brackets are typically used to declare, initialize and index (indicate which element of) arrays5]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) arrays5]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
20 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer r=this assignment operator makes the left side equal to the right side0; r<cells.length; r++this is the increment operator, which increases the variable by 1)
21 {open braces start code blocks and must be matched with a close brace
22 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer c=this assignment operator makes the left side equal to the right side0; c<cells[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.length; c++this is the increment operator, which increases the variable by 1)
23 {open braces start code blocks and must be matched with a close brace
24 cells[brackets are typically used to declare, initialize and index (indicate which element of) arraysr]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) arraysc]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right sidefalsefalse is a value for the boolean type and means not true;
25 }close braces end code blocks and must match an earlier open brace
26 }close braces end code blocks and must match an earlier open brace
27 java.util.Random random=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor java.util.Random();
28 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer k=this assignment operator makes the left side equal to the right side0; k<10; k++this is the increment operator, which increases the variable by 1)
29 play(random.nextInt(cells.length),random.nextInt(cells[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.length));
30 }close braces end code blocks and must match an earlier open brace
31
32 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value play(intint is the type for whole numbers and it is short for integer row, intint is the type for whole numbers and it is short for integer col)
33 {open braces start code blocks and must be matched with a close brace
34 cells[brackets are typically used to declare, initialize and index (indicate which element of) arraysrow]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) arrayscol]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right side!this is the not operator, which changes true to false and false to truecells[brackets are typically used to declare, initialize and index (indicate which element of) arraysrow]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) arrayscol]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
35 ifif executes the next statement only if the condition in parenthesis evaluates to true(row-1>=this evaluates to true if the left side is not less than the right side0)
36 cells[brackets are typically used to declare, initialize and index (indicate which element of) arraysrow-1]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) arrayscol]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right side!this is the not operator, which changes true to false and false to truecells[brackets are typically used to declare, initialize and index (indicate which element of) arraysrow-1]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) arrayscol]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
37 ifif executes the next statement only if the condition in parenthesis evaluates to true(row+adds two numbers together or concatenates Strings together1<=this evaluates to true if the left side is not more than the right side4)
38 cells[brackets are typically used to declare, initialize and index (indicate which element of) arraysrow+adds two numbers together or concatenates Strings together1]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) arrayscol]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right side!this is the not operator, which changes true to false and false to truecells[brackets are typically used to declare, initialize and index (indicate which element of) arraysrow+adds two numbers together or concatenates Strings together1]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) arrayscol]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
39 ifif executes the next statement only if the condition in parenthesis evaluates to true(col-1>=this evaluates to true if the left side is not less than the right side0)
40 cells[brackets are typically used to declare, initialize and index (indicate which element of) arraysrow]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) arrayscol-1]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right side!this is the not operator, which changes true to false and false to truecells[brackets are typically used to declare, initialize and index (indicate which element of) arraysrow]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) arrayscol-1]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
41 ifif executes the next statement only if the condition in parenthesis evaluates to true(col+adds two numbers together or concatenates Strings together1<=this evaluates to true if the left side is not more than the right side4)
42 cells[brackets are typically used to declare, initialize and index (indicate which element of) arraysrow]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) arrayscol+adds two numbers together or concatenates Strings together1]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right side!this is the not operator, which changes true to false and false to truecells[brackets are typically used to declare, initialize and index (indicate which element of) arraysrow]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) arrayscol+adds two numbers together or concatenates Strings together1]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
43 }close braces end code blocks and must match an earlier open brace
44
45 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false won()
46 {open braces start code blocks and must be matched with a close brace
47 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side0; i<cells.length; i++this is the increment operator, which increases the variable by 1)
48 {open braces start code blocks and must be matched with a close brace
49 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer j=this assignment operator makes the left side equal to the right side0; j<cells[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.length; j++this is the increment operator, which increases the variable by 1)
50 {open braces start code blocks and must be matched with a close brace
51 ifif executes the next statement only if the condition in parenthesis evaluates to true(cells[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]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) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays==this is the comparison operator which evaluates to true if both sides are the sametruetrue is the boolean value that is the opposite of false)
52 {open braces start code blocks and must be matched with a close brace
53 returnreturn means to provide the result of the method and/or cease execution of the method immediately falsefalse is a value for the boolean type and means not true;
54 }close braces end code blocks and must match an earlier open brace
55 }close braces end code blocks and must match an earlier open brace
56 }close braces end code blocks and must match an earlier open brace
57 returnreturn means to provide the result of the method and/or cease execution of the method immediately truetrue is the boolean value that is the opposite of false;
58 }close braces end code blocks and must match an earlier open brace
59
60 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false isOn(intint is the type for whole numbers and it is short for integer row, intint is the type for whole numbers and it is short for integer col)
61 {open braces start code blocks and must be matched with a close brace
62 returnreturn means to provide the result of the method and/or cease execution of the method immediately cells[brackets are typically used to declare, initialize and index (indicate which element of) arraysrow]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) arrayscol]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
63 }close braces end code blocks and must match an earlier open brace
64
65 publicpublic is used to indicate unrestricted access (any other class can have access) String toString()
66 {open braces start code blocks and must be matched with a close brace
67 String total=this assignment operator makes the left side equal to the right side"";
68 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer r=this assignment operator makes the left side equal to the right side0; r<cells.length; r++this is the increment operator, which increases the variable by 1)
69 {open braces start code blocks and must be matched with a close brace
70 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer c=this assignment operator makes the left side equal to the right side0; c<cells[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.length; c++this is the increment operator, which increases the variable by 1)
71 {open braces start code blocks and must be matched with a close brace
72 total+=this increases the variable on the left by the value on the rightcells[brackets are typically used to declare, initialize and index (indicate which element of) arraysr]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) arraysc]brackets are typically used to declare, initialize and index (indicate which element of) arrays+adds two numbers together or concatenates Strings together"\t";
73 }close braces end code blocks and must match an earlier open brace
74 total+=this increases the variable on the left by the value on the right"\n";
75 }close braces end code blocks and must match an earlier open brace
76 returnreturn means to provide the result of the method and/or cease execution of the method immediately total;
77 }close braces end code blocks and must match an earlier open brace
78 }close braces end code blocks and must match an earlier open brace
|