From ggc
|
01 packagepackage is used to name the directory or folder a class is in jam;
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 Jam Jenkins
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 Door
09 {open braces start code blocks and must be matched with a close brace
10 /**truetrue is the boolean value that is the opposite of false means good prize, falsefalse is a value for the boolean type and means not true means bad prize*/
11 privateprivate is used to restrict access to the current class only booleanboolean is a type that is either true or false prize;
12 privateprivate is used to restrict access to the current class only booleanboolean is a type that is either true or false opened;
13 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer number;
14
15 publicpublic is used to indicate unrestricted access (any other class can have access) Door()
16 {open braces start code blocks and must be matched with a close brace
17 prize=this assignment operator makes the left side equal to the right sidetruetrue is the boolean value that is the opposite of false;
18 opened=this assignment operator makes the left side equal to the right sidefalsefalse is a value for the boolean type and means not true;
19 number=this assignment operator makes the left side equal to the right side0;
20 }close braces end code blocks and must match an earlier open brace
21
22 publicpublic is used to indicate unrestricted access (any other class can have access) Door(booleanboolean is a type that is either true or false prize, booleanboolean is a type that is either true or false opened, intint is the type for whole numbers and it is short for integer number)
23 {open braces start code blocks and must be matched with a close brace
24 thisthis means the current object (the implicit parameter).prize=this assignment operator makes the left side equal to the right sideprize;
25 thisthis means the current object (the implicit parameter).opened=this assignment operator makes the left side equal to the right sideopened;
26 thisthis means the current object (the implicit parameter).number=this assignment operator makes the left side equal to the right sidenumber;
27 }close braces end code blocks and must match an earlier open brace
28
29 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value open()
30 {open braces start code blocks and must be matched with a close brace
31 opened=this assignment operator makes the left side equal to the right sidetruetrue is the boolean value that is the opposite of false;
32 }close braces end code blocks and must match an earlier open brace
33
34 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false isPrize()
35 {open braces start code blocks and must be matched with a close brace
36 returnreturn means to provide the result of the method and/or cease execution of the method immediately prize;
37 }close braces end code blocks and must match an earlier open brace
38
39 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false isOpen()
40 {open braces start code blocks and must be matched with a close brace
41 returnreturn means to provide the result of the method and/or cease execution of the method immediately opened;
42 }close braces end code blocks and must match an earlier open brace
43
44 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false canOpenFirst(intint is the type for whole numbers and it is short for integer doorChosen)
45 {open braces start code blocks and must be matched with a close brace
46 ifif executes the next statement only if the condition in parenthesis evaluates to true(!this is the not operator, which changes true to false and false to trueprize &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 &&) doorChosen!=this is the not equals operator which evaluates to true if both sides are differentnumber)
47 //if(prize==false && doorChosen!=number)
48 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;
49 elseelse is what happens when the if condition is false
50 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;
51 }close braces end code blocks and must match an earlier open brace
52
53 publicpublic is used to indicate unrestricted access (any other class can have access) String toString()
54 {open braces start code blocks and must be matched with a close brace
55 String toReturn=this assignment operator makes the left side equal to the right side"Door number "+adds two numbers together or concatenates Strings togethernumber;
56 ifif executes the next statement only if the condition in parenthesis evaluates to true(opened) toReturn+=this increases the variable on the left by the value on the right" is open";
57 elseelse is what happens when the if condition is false toReturn+=this increases the variable on the left by the value on the right" is closed";
58 ifif executes the next statement only if the condition in parenthesis evaluates to true(prize) toReturn+=this increases the variable on the left by the value on the right" and has the prize.";
59 elseelse is what happens when the if condition is false toReturn+=this increases the variable on the left by the value on the right" and does not have the prize.";
60 returnreturn means to provide the result of the method and/or cease execution of the method immediately toReturn;
61 }close braces end code blocks and must match an earlier open brace
62 }close braces end code blocks and must match an earlier open brace
|
Download/View jam/Door.java