From ggc
|
01 packagepackage is used to name the directory or folder a class is in intermediate;
02 //start auto-imports
03 importimport means to make the classes and/or packages available in this program java.awt.*;
04 //end auto-imports
05
06
07 /**
08 * All about my helper classclass is a group of fields and methods used for making objects.
09 * @authorthis is the Javadoc tag for documenting who created the source code My Name Here
10 */
11 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 Rational
12 {open braces start code blocks and must be matched with a close brace
13 privateprivate is used to restrict access to the current class only Point numbers;
14
15 publicpublic is used to indicate unrestricted access (any other class can have access) Rational(intint is the type for whole numbers and it is short for integer n, intint is the type for whole numbers and it is short for integer d)
16 {open braces start code blocks and must be matched with a close brace
17 ifif executes the next statement only if the condition in parenthesis evaluates to true(d==this is the comparison operator which evaluates to true if both sides are the same0)
18 {open braces start code blocks and must be matched with a close brace
19 numbers=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Point(0, 1);
20 }close braces end code blocks and must match an earlier open brace
21 elseelse is what happens when the if condition is false
22 {open braces start code blocks and must be matched with a close brace
23 numbers=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Point(n, d);
24 }close braces end code blocks and must match an earlier open brace
25 }close braces end code blocks and must match an earlier open brace
26
27 publicpublic is used to indicate unrestricted access (any other class can have access) doubledouble is the type for numbers that can contain decimal fractions getValue()
28 {open braces start code blocks and must be matched with a close brace
29 returnreturn means to provide the result of the method and/or cease execution of the method immediately (doubledouble is the type for numbers that can contain decimal fractions)numbers.x/numbers.y;
30 }close braces end code blocks and must match an earlier open brace
31
32 publicpublic is used to indicate unrestricted access (any other class can have access) Point getPair()
33 {open braces start code blocks and must be matched with a close brace
34 //return numbers;
35 Point result=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Point(numbers.x, numbers.y);
36 returnreturn means to provide the result of the method and/or cease execution of the method immediately result;
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) intint is the type for whole numbers and it is short for integer getDenominator()
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 numbers.y;
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) staticstatic means that an instance is not required for access (class level access) doubledouble is the type for numbers that can contain decimal fractions getEpsilon()
45 {open braces start code blocks and must be matched with a close brace
46 returnreturn means to provide the result of the method and/or cease execution of the method immediately 1e-10;
47 }close braces end code blocks and must match an earlier open brace
48 }close braces end code blocks and must match an earlier open brace
|
Download/View intermediate/Rational.java