From ggc
|
01 packagepackage is used to name the directory or folder a class is in intro;
02
03 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 Model
04 {open braces start code blocks and must be matched with a close brace
05 privateprivate is used to restrict access to the current class only String color;
06
07 publicpublic is used to indicate unrestricted access (any other class can have access) Model()
08 {open braces start code blocks and must be matched with a close brace
09 color=this assignment operator makes the left side equal to the right side"red";
10 }close braces end code blocks and must match an earlier open brace
11
12 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value toggle()
13 {open braces start code blocks and must be matched with a close brace
14 ifif executes the next statement only if the condition in parenthesis evaluates to true(color.equals("red"))
15 {open braces start code blocks and must be matched with a close brace
16 color=this assignment operator makes the left side equal to the right side"yellow";
17 }close braces end code blocks and must match an earlier open brace
18 elseelse is what happens when the if condition is false
19 {open braces start code blocks and must be matched with a close brace
20 color=this assignment operator makes the left side equal to the right side"red";
21 }close braces end code blocks and must match an earlier open brace
22 }close braces end code blocks and must match an earlier open brace
23
24 publicpublic is used to indicate unrestricted access (any other class can have access) String getColor()
25 {open braces start code blocks and must be matched with a close brace
26 returnreturn means to provide the result of the method and/or cease execution of the method immediately color;
27 }close braces end code blocks and must match an earlier open brace
28 }close braces end code blocks and must match an earlier open brace
|
Download/View intro/Model.java