APCS
linked lists - a
short applet
assignment
Design an applet
to maintain a list of cities and states. Your applet should allow
a user to add a city to the front or back of the list as well as to
remove a city from the respective locations. Your applet should
also allow the user to display the node count as well as a clear option
which should empty the list.
You will need to
design and implement the following classes:
- City class:
- represents
the city name and state stored as separate String
objects.
- City
methods:
- constructor
- getCity()
- getState()
- toString()
- setCity()
- setState()
- ListNode
class: [available here and on p.268 in APCS study guide]
- represents
a node in a LinkedList
- ListNode
methods:
- constructor
- getValue()
- getNext()
- setValue()
- setNext()
- LList
class: [available here and on p. 270 in APCS study guide]
- represents
a linked list of ListNodes
- LList
methods:
- default
constructor
- getFirst()
- addFirst()
- removeFirst()
- getLast()
[p.273]
- addlLast()
[p.273]
- removeLast()
[p.273]
- empty() -
removes all nodes from list.
- length()
- returns int that reprsents the number of nodes in list
- toString()
- returns a String representation of linked lists