From ggc
|
001 packagepackage is used to name the directory or folder a class is in intermediate;
002 //start auto-imports
003 importimport means to make the classes and/or packages available in this program com.sun.org.apache.bcel.internal.generic.*;
004 importimport means to make the classes and/or packages available in this program java.util.*;
005 //end auto-imports
006
007
008 /**
009 * All about my application.
010 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
011 */
012 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 ProfileADT
013 {open braces start code blocks and must be matched with a close brace
014 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) classclass is a group of fields and methods used for making objects Linky<T>
015 {open braces start code blocks and must be matched with a close brace
016 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 Node<T>
017 {open braces start code blocks and must be matched with a close brace
018 T data;
019 Node<T> next;
020 }close braces end code blocks and must match an earlier open brace
021
022 privateprivate is used to restrict access to the current class only Node<T> head;
023
024 publicpublic is used to indicate unrestricted access (any other class can have access) Linky()
025 {open braces start code blocks and must be matched with a close brace
026 head=this assignment operator makes the left side equal to the right sidenullnull is the value used to refer to a non-existant object;
027 }close braces end code blocks and must match an earlier open brace
028
029 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false isEmpty()
030 {open braces start code blocks and must be matched with a close brace
031 returnreturn means to provide the result of the method and/or cease execution of the method immediately head==this is the comparison operator which evaluates to true if both sides are the samenullnull is the value used to refer to a non-existant object;
032 }close braces end code blocks and must match an earlier open brace
033
034 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value addFirst(T data)
035 {open braces start code blocks and must be matched with a close brace
036 ifif executes the next statement only if the condition in parenthesis evaluates to true(isEmpty())
037 {open braces start code blocks and must be matched with a close brace
038 Node<T> node=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Node<T>();
039 node.data=this assignment operator makes the left side equal to the right sidedata;
040 node.next=this assignment operator makes the left side equal to the right sidenullnull is the value used to refer to a non-existant object;
041 head=this assignment operator makes the left side equal to the right sidenode;
042 }close braces end code blocks and must match an earlier open brace
043 elseelse is what happens when the if condition is false
044 {open braces start code blocks and must be matched with a close brace
045 Node<T> node=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Node<T>();
046 node.data=this assignment operator makes the left side equal to the right sidedata;
047 node.next=this assignment operator makes the left side equal to the right sidehead;
048 head=this assignment operator makes the left side equal to the right sidenode;
049 }close braces end code blocks and must match an earlier open brace
050 }close braces end code blocks and must match an earlier open brace
051
052 publicpublic is used to indicate unrestricted access (any other class can have access) T removeFirst()
053 {open braces start code blocks and must be matched with a close brace
054 ifif executes the next statement only if the condition in parenthesis evaluates to true(isEmpty())
055 returnreturn means to provide the result of the method and/or cease execution of the method immediately nullnull is the value used to refer to a non-existant object;
056 T data=this assignment operator makes the left side equal to the right sidehead.data;
057 head=this assignment operator makes the left side equal to the right sidehead.next;
058 returnreturn means to provide the result of the method and/or cease execution of the method immediately data;
059 }close braces end code blocks and must match an earlier open brace
060
061 publicpublic is used to indicate unrestricted access (any other class can have access) String toString()
062 {open braces start code blocks and must be matched with a close brace
063 String result=this assignment operator makes the left side equal to the right side"head->";
064 Node<T> current=this assignment operator makes the left side equal to the right sidehead;
065 whilewhile is a looping structure for executing code repeatedly(current!=this is the not equals operator which evaluates to true if both sides are differentnullnull is the value used to refer to a non-existant object)
066 {open braces start code blocks and must be matched with a close brace
067 result+=this increases the variable on the left by the value on the rightcurrent.data+adds two numbers together or concatenates Strings together"->";
068 current=this assignment operator makes the left side equal to the right sidecurrent.next;
069 }close braces end code blocks and must match an earlier open brace
070 result+=this increases the variable on the left by the value on the right"null";
071 returnreturn means to provide the result of the method and/or cease execution of the method immediately result;
072 }close braces end code blocks and must match an earlier open brace
073 }close braces end code blocks and must match an earlier open brace
074
075 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 fill(List list, intint is the type for whole numbers and it is short for integer size)
076 {open braces start code blocks and must be matched with a close brace
077 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side0; i<size; i++this is the increment operator, which increases the variable by 1)
078 {open braces start code blocks and must be matched with a close brace
079 intint is the type for whole numbers and it is short for integer number=this assignment operator makes the left side equal to the right side(intint is the type for whole numbers and it is short for integer)(Math.random()*100000);
080 list.add(0, number);
081 }close braces end code blocks and must match an earlier open brace
082 }close braces end code blocks and must match an earlier open brace
083
084
085 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) intint is the type for whole numbers and it is short for integer getMiddle(List<Integer> list)
086 {open braces start code blocks and must be matched with a close brace
087 returnreturn means to provide the result of the method and/or cease execution of the method immediately list.get(list.size()/2);
088 }close braces end code blocks and must match an earlier open brace
089
090 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)
091 {open braces start code blocks and must be matched with a close brace
092 Linky<String> linky=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Linky<String>();
093 System.out.println(linky);
094 linky.addFirst("Jam");
095 System.out.println(linky);
096 linky.addFirst("Jelly");
097 System.out.println(linky);
098 linky.addFirst("Roll");
099 System.out.println(linky);
100 String data=this assignment operator makes the left side equal to the right sidelinky.removeFirst();
101 System.out.println("Removed first: "+adds two numbers together or concatenates Strings togetherdata);
102 System.out.println("List is now: "+adds two numbers together or concatenates Strings togetherlinky);
103
104 /*
105 LinkedList<Integer> list=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor LinkedList<Integer>();
106 ArrayList<Integer> random=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ArrayList<Integer>();
107 fill(random, 100);
108 longlong is the type for whole numbers (they have a larger range than int) start=this assignment operator makes the left side equal to the right sideSystem.currentTimeMillis();
109 longlong is the type for whole numbers (they have a larger range than int) count=this assignment operator makes the left side equal to the right side0;
110 whilewhile is a looping structure for executing code repeatedly(System.currentTimeMillis()<start+adds two numbers together or concatenates Strings together1000)
111 {open braces start code blocks and must be matched with a close brace
112 random.get(random.size()-1);//getMiddle(random);
113 count++this is the increment operator, which increases the variable by 1;
114 }close braces end code blocks and must match an earlier open brace
115 System.out.println("Random access add: "+adds two numbers together or concatenates Strings togethercount);
116 fill(list, 100);
117 start=this assignment operator makes the left side equal to the right sideSystem.currentTimeMillis();
118 count=this assignment operator makes the left side equal to the right side0;
119 whilewhile is a looping structure for executing code repeatedly(System.currentTimeMillis()<start+adds two numbers together or concatenates Strings together1000)
120 {open braces start code blocks and must be matched with a close brace
121 list.get(list.size()-1);//getMiddle(list);
122 count++this is the increment operator, which increases the variable by 1;
123 }close braces end code blocks and must match an earlier open brace
124 System.out.println("Sequential access add: "+adds two numbers together or concatenates Strings togethercount);
125 */
126 }close braces end code blocks and must match an earlier open brace
127 }close braces end code blocks and must match an earlier open brace
|
Download/View intermediate/ProfileADT.java