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 java.awt.geom.*;
04 importimport means to make the classes and/or packages available in this program wiki.Wiki;
05 /**
06 * All about my classclass is a group of fields and methods used for making objects here.
07 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
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 VectorAdder
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) staticstatic means that an instance is not required for access (class level access) finalfinal means not changeable (often used for constants) intint is the type for whole numbers and it is short for integer ZERO=this assignment operator makes the left side equal to the right side0;
12
13 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) Point2D.Double add(Point2D.Double one, Point2D.Double two)
14 {open braces start code blocks and must be matched with a close brace
15 //one.x+=two.x;
16 //one.y+=two.y;
17 //return one;
18 //above has bad sad effect
19 returnreturn means to provide the result of the method and/or cease execution of the method immediately newnew is used to create objects by calling the constructor Point2D.Double(one.x+adds two numbers together or concatenates Strings togethertwo.x, one.y+adds two numbers together or concatenates Strings togethertwo.y);
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) Point2D.Double instanceAdd(Point2D.Double one, Point2D.Double two)
23 {open braces start code blocks and must be matched with a close brace
24 //one.x+=two.x;
25 //one.y+=two.y;
26 //return one;
27 //above has bad sad effect
28 returnreturn means to provide the result of the method and/or cease execution of the method immediately newnew is used to create objects by calling the constructor Point2D.Double(one.x+adds two numbers together or concatenates Strings togethertwo.x, one.y+adds two numbers together or concatenates Strings togethertwo.y);
29 }close braces end code blocks and must match an earlier open brace
30
31 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)
32 {open braces start code blocks and must be matched with a close brace
33 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 side7+adds two numbers together or concatenates Strings togetherZERO;
34 //ZERO=1;//can't do this
35 Point2D.Double a=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Point2D.Double(1, 3);
36 Point2D.Double b=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Point2D.Double(2, 6);
37 VectorAdder adder=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor VectorAdder();
38 Point2D.Double result=this assignment operator makes the left side equal to the right sideadder.instanceAdd(a, b);
39 Wiki.out.println(a);
40 Wiki.out.println("plus");
41 Wiki.out.println(b);
42 Wiki.out.println("is");
43 Wiki.out.println(result);
44 }close braces end code blocks and must match an earlier open brace
45 }close braces end code blocks and must match an earlier open brace
|
Download/View jam/VectorAdder.java