From ggc
|
01 //package lightsout;
02 packagepackage is used to name the directory or folder a class is in Jayson.lightsout;
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 * Starts of the light out game. Checks ifif executes the next statement only if the condition in parenthesis evaluates to true the user wants a GUI or Text Interface
07 * @authorthis is the Javadoc tag for documenting who created the source code Jpark
08 */
09 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 LightsOutStart
10 {open braces start code blocks and must be matched with a close brace
11 publicpublic is used to indicate unrestricted access (any other class can have access) LightsOutStart()
12 {open braces start code blocks and must be matched with a close brace}close braces end code blocks and must match an earlier open brace
13 /**Main method*/
14 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)
15 {open braces start code blocks and must be matched with a close brace
16 LightsOutStart lightsoutstart =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor LightsOutStart();
17 Wiki.out.print("Which interface would you like to use:\nText or GUI?");
18 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);
19 String choice=this assignment operator makes the left side equal to the right sidescanner.next();
20 Wiki.out.println(choice);
21 whilewhile is a looping structure for executing code repeatedly(!this is the not operator, which changes true to false and false to truechoice.equals("Text") &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 &&) !this is the not operator, which changes true to false and false to truechoice.equals("GUI"))
22 {open braces start code blocks and must be matched with a close brace
23 Wiki.out.println("Please type Text or GUI.");
24 Wiki.out.print("Which interface would you like to use:\nText or GUI?");
25 choice =this assignment operator makes the left side equal to the right side scanner.next();
26 }close braces end code blocks and must match an earlier open brace
27 ifif executes the next statement only if the condition in parenthesis evaluates to true(choice.equals("Text"))
28 {open braces start code blocks and must be matched with a close brace
29 LightsOutText.mainThe main method is the place where applications begin executing.(nullnull is the value used to refer to a non-existant object);
30 }close braces end code blocks and must match an earlier open brace
31 elseelse is what happens when the if condition is false
32 {open braces start code blocks and must be matched with a close brace
33 LightsOut.mainThe main method is the place where applications begin executing.(nullnull is the value used to refer to a non-existant object);
34 }close braces end code blocks and must match an earlier open brace
35 }close braces end code blocks and must match an earlier open brace
36 }close braces end code blocks and must match an earlier open brace
|
Download/View Jayson/lightsout/LightsOutStart.java