From ggc
|
01 packagepackage is used to name the directory or folder a class is in intermediate;
02
03
04 importimport means to make the classes and/or packages available in this program java.util.ArrayList;
05
06 /**
07 * This classclass is a group of fields and methods used for making objects provides the shell forfor is a looping structure for repeatedly executing a block of code testing
08 * an implementation of the DefiniteNumericColleciton.
09 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
10 *
11 */
12 publicpublic is used to indicate unrestricted access (any other class can have access) abstractAbstract means there is implementation missing. classclass is a group of fields and methods used for making objects DefiniteNumericCollectionTest
13 {open braces start code blocks and must be matched with a close brace
14 /**the description of the tests passed*/
15 protectedprotected is used to restrict access to the current class and subclasses only ArrayList<String> passed;
16 /**the description of the tests failed*/
17 protectedprotected is used to restrict access to the current class and subclasses only ArrayList<String> failed;
18
19 /**makes the test*/
20 publicpublic is used to indicate unrestricted access (any other class can have access) DefiniteNumericCollectionTest()
21 {open braces start code blocks and must be matched with a close brace
22 passed=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ArrayList<String>();
23 failed=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ArrayList<String>();
24 }close braces end code blocks and must match an earlier open brace
25
26 /**
27 * thisthis means the current object (the implicit parameter) method should run tests and add
28 * to the passed and failed ArrayList
29 * collections the names of those tests
30 * that pass and fail
31 */
32 publicpublic is used to indicate unrestricted access (any other class can have access) abstractAbstract means there is implementation missing. voidvoid means the method does not return a value runTests(DefiniteNumericCollection collection);
33
34 /**
35 * gets the description of the tests
36 * that passed
37 * @returnnull text describing passed tests
38 */
39 publicpublic is used to indicate unrestricted access (any other class can have access) String getPassReport()
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 getReport(passed);
42 }close braces end code blocks and must match an earlier open brace
43 /**
44 * gets the description of the tests
45 * that failed
46 * @returnnull text describing failed tests
47 */
48 publicpublic is used to indicate unrestricted access (any other class can have access) String getFailReport()
49 {open braces start code blocks and must be matched with a close brace
50 returnreturn means to provide the result of the method and/or cease execution of the method immediately getReport(failed);
51 }close braces end code blocks and must match an earlier open brace
52
53 /**
54 * converts the arraylist into messages
55 * separated by blank lines
56 * @paramthis is the Javadoc tag for documenting the purpose of parameters names the description of passed
57 * or failed tests
58 * @returnnull a single String containing all
59 * of the contents of the ArrayList, each
60 * separated by a blank line
61 */
62 privateprivate is used to restrict access to the current class only staticstatic means that an instance is not required for access (class level access) String getReport(ArrayList<String> names)
63 {open braces start code blocks and must be matched with a close brace
64 String report=this assignment operator makes the left side equal to the right side"";
65 forfor is a looping structure for repeatedly executing a block of code(String name: names)
66 {open braces start code blocks and must be matched with a close brace
67 report+=this increases the variable on the left by the value on the rightname+adds two numbers together or concatenates Strings together"\n\n";
68 }close braces end code blocks and must match an earlier open brace
69 ifif executes the next statement only if the condition in parenthesis evaluates to true(report.length()>0)
70 report=this assignment operator makes the left side equal to the right sidereport.substring(0, report.length()-2);
71 returnreturn means to provide the result of the method and/or cease execution of the method immediately report;
72 }close braces end code blocks and must match an earlier open brace
73
74 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)
75 {open braces start code blocks and must be matched with a close brace
76 //DefiniteNumericCollectionTest test=new DefiniteNumericCollectionTest();
77 }close braces end code blocks and must match an earlier open brace
78 }close braces end code blocks and must match an earlier open brace
|
Download/View intermediate/DefiniteNumericCollectionTest.java