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 FatCat implementsimplements means providing method bodies for the methods declared in the corresponding interface Comparable<FatCat>
09 {open braces start code blocks and must be matched with a close brace
10 privateprivate is used to restrict access to the current class only String name;
11 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer weight;
12
13 publicpublic is used to indicate unrestricted access (any other class can have access) FatCat(String name, intint is the type for whole numbers and it is short for integer weight)
14 {open braces start code blocks and must be matched with a close brace
15 thisthis means the current object (the implicit parameter).name=this assignment operator makes the left side equal to the right sidename;
16 thisthis means the current object (the implicit parameter).weight=this assignment operator makes the left side equal to the right sideweight;
17 }close braces end code blocks and must match an earlier open brace
18
19 publicpublic is used to indicate unrestricted access (any other class can have access) String toString()
20 {open braces start code blocks and must be matched with a close brace
21 returnreturn means to provide the result of the method and/or cease execution of the method immediately name+adds two numbers together or concatenates Strings together" weighing "+adds two numbers together or concatenates Strings togetherweight+adds two numbers together or concatenates Strings together" lbs";
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) intint is the type for whole numbers and it is short for integer compareTo(FatCat cat)
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 thisthis means the current object (the implicit parameter).weight-cat.weight;
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 jam/FatCat.java