Student
- lastName : String
- firstName : String
- state : String
- major : String
+ createStudent()
+ getFirstName()
+ setFirstName()
+ getLastName()
+ setLastName()
+ getState()
+ setState()
+ getMajor()
+ setMajor()
+ getRate()
- isStateValid()
- isMajorValid()
Student
- lastName : String
- firstName : String
- state : String
- major : String
+ createStudent()
+ getFirstName()
+ setFirstName()
+ getLastName()
+ setLastName()
+ getState()
+ setState()
+ getMajor()
+ setMajor()
+ getRate()
- isStateValid()
- isMajorValid()
Student
- lastName : String
- firstName : String
- state : String
- major : String
+ createStudent()
+ getFirstName() : String
+ setFirstName() : void
+ getLastName() : String
+ setLastName() : void
+ getState() : String
+ setState() : void
+ getMajor() : String
+ setMajor() : void
+ getRate() : int
- isStateValid(): boolean
- isMajorValid() : boolean
Lee aaaa Dan cccc Joe ffff Bob null
abcd
head
abcd aaaa cccc ffff
Node
- data : Object
- link : Node
+ createNode()
+ getData() : Object
+ setData() : void
+ getLink() : Node
+ setLink() : void
Lee aaaa Dan cccc Joe ffff Bob null
abcd Barb cccc
abcd aaaa cccc ffff
xxxx
head
link = new Node( data, link );
Lee aaaa Dan xxxx Joe ffff Bob null
abcd Barb cccc
abcd aaaa cccc ffff
xxxx
head
Lee aaaa Dan cccc Joe ffff Bob null
abcd
abcd aaaa cccc ffff
head
link = link.link;
Lee aaaa Dan ffff Joe ffff Bob null
abcd
abcd aaaa cccc ffff
head
Node
- data : Object
- link : Node
+ createNode()
+ getData() : Object
+ setData() : void
+ getLink() : Node
+ setLink() : void
+ addNodeAfter() : void
+ removeNodeAfter() : void
Traversing a Linked ListTraversing a Linked List
Node current = head; while( current != null ) { System.out.println( current.getData() ); current = current.getLink(); }
Adding a Node to the End of Adding a Node to the End of the Listthe List
if( head == null ) head = new Node( data, null );else{ Node current = head; while( current.getLink() != null ) current = current.getLink(); current.addNodeAfter( data );}
LinkedList
- head : Node
+ createLinkedList()
+ add(Object)
+ add(Object, int)
+ clear()
+ get(int) : Node
+ isEmpty() : boolean
+ size() : int
+ find(Object) : int
+ remove(Object)
+ remove(int)
- getReference(int) : Node
Node
- data : Object
- link : Node
+ createNode()
+ getData()
+ setData()
+ getLink()
+ setLink()
+ addNodeAfter()
+ removeNodeAfter()
0..* 1
LinkedList
- head : Node
+ createLinkedList()
+ add(Object)
+ add(Object, int)
+ clear()
+ get(int) : Node
+ isEmpty() : boolean
+ size() : int
+ find(Object) : int
+ remove(Object)
+ remove(int)
- getReference(int) : Node
UML “Has A” RelationshipUML “Has A” Relationship
Another Use of "Has A"Another Use of "Has A"
Employee
- home : HomeAddress
- job : JobInfo
- insurance : Insurance
- ssn : String
- lastName : String
- firstName : String
+ createEmployee()
+ getSSN() : String
+ setSSN()
+ getFirstName() : String
+ setFirstName()
+ getLastName() : String
+ setLastName()
HomeAddress
- street : String
- addr2 : String
- city : String
- state : String
- zip : String
+ getStreet() : String
+ setStreet()
+ getAddr2() : String
+ setString()
. . .
1 1
JobInfo
- jobCode : String
- title : String
- salary : String
- location : JobAddress
- startDate : Date
+ getJobCode() : String
+ setJobCode()
+ getTitle() : String
+ setTitle()
. . .
1 0..*
StacksStacks
Stack
- stack : LinkedList
+ createStack()
+ push( Object )
+ pop() : Object
+ peek() : Object
+ isEmpty() : boolean
QueuesQueues
Queue
- queue : LinkedList
+ createQueue()
+ enqueue( Object )
+ dequeue() : Object
+ size() : int
+ isEmpty() : boolean
Priority QueuePriority Queue
1
2
3
4
3
Priority QueuePriority Queue
1
2
3
4
2
Priority QueuePriority Queue
1
2
3
4
3
Priority QueuePriority Queue
1
2
3
4
1
Priority QueuePriority Queue
1
2
3
4
Priority QueuePriority Queue
1
2
3
4
1
Priority QueuePriority Queue
1
2
3
4
Priority QueuePriority Queue
1
2
3
4
Priority QueuePriority Queue
1
2
3
4
Priority QueuePriority Queue
1
2
3
4
4 Queue Methods for Priority 4 Queue Methods for Priority QueueQueue
enqueue(Object, int) - Add a node in the priority specified by the int
dequeue() - Loop through the priorities, dequeue a node from the highest priority that has one
size() - Loop through all priorities, summing and returning number of nodes.
isEmpty() - If all priorities are empty, return true
LinkedList
- head : Node
+ createLinkedList()
+ add(Object)
+ add(Object, int)
+ clear()
+ get(int) : Node
+ isEmpty() : boolean
+ size() : int
+ find(Object) : int
+ remove(Object)
+ remove(int)
- getReference(int) : Node
Stack
- stack : LinkedList
+ createStack()
+ push( Object )
+ pop() : Object
+ peek() : Object
+ isEmpty() : boolean
1 1