CSIT 254 BBC Programming Lab

CSIT254 Programming Lab 4 – Linked ListsOverview
This lab is to expose you to a single Linked List of String.
The Lab
You are to write the code for StringNode and StringLinkedBag. The iteratorPrototype() method is
already written for you within StringLinked Bag.
See the UML diagrams attached; change IntNode to StringNode, and IntLinkedBag to StringLinkedBag.
Refresh your memory by looking at the power point slides to see the changes that should be made when
using the String class. Make sure you put in your Javadoc comments for StringNode and
StringLinkedBag, as well as follow the coding standards discussed in class.
Make sure you add your name to the comments in each .java file.
Grading Rubric
StringNode (45 points)
• Comment in program with name (2 points)
• Declaration of variables up top (5 points)
• Constructor, 2 getters and 2 setters for the private data members (5 pts each totaling 25 points)
• following the naming guidelines for Classes and identifiers (8 points)
• proper indenting (5 points)
• Remember starting with this lab, it must compile and run or it is a 0.
StringLinkedBag (55 points)
• Comment in program with name (2 points)
• Declaration of variables up top (4 points)
• Constructor, getSize(), add(), remove(), exists(), countOccurences() (6 pts each totaling 36 pts)
o Remember iteratorPrototype() is written for you
• following the naming guidelines for Classes and identifiers (8 points)
• proper indenting (5 points)
• Remember starting with this lab, it must compile and run or it is a 0.
Remember the coding standards:






make sure you follow the naming guidelines for variable names – self descriptive, begins with
lower case and follows camel case style
make sure your class names begins with upper case and follow camel case style
make sure your code is properly indented (use format in netbeans if you are not sure)
make sure you add white space to your code
make sure all variables are declared at the top of the code
make sure your StringLinkedBag.java file compiles and your StringNode compiles.
Submitting the Lab
Submit the .zip file on Canvas.
1
CSIT254 Programming Lab 4 – Linked Lists
Sample run without a..z order (without extra credit)
fruitBag upon startup
n=0 Bag: size is 0, therefore assumed Empty
added Pear… Size: 1
added Plum… Size: 2
added Watermellon… Size: 3
added Mango…
Size: 4
added Apple… Size: 5
added Nectarine… Size: 6
added Cherry…
Size: 7
fruitBag after 7 adds
n=7 Bag: {Pear}, {Plum}, {Watermellon}, {Mango}, {Apple}, {Nectarine}, {Cherry}
No! No banana in the fruitBag
Yes! There is a nectarine in the fruitBag!
Yes! There is a watermellon in the fruitBag!
fruitBag before removing banana
n=7 Bag: {Pear}, {Plum}, {Watermellon}, {Mango}, {Apple}, {Nectarine}, {Cherry}
Sorry! unable to remove banana from fruitBag!
fruitBag after removing banana
n=7 Bag: {Pear}, {Plum}, {Watermellon}, {Mango}, {Apple}, {Nectarine}, {Cherry}
fruitBag before removing watermellon
n=7 Bag: {Pear}, {Plum}, {Watermellon}, {Mango}, {Apple}, {Nectarine}, {Cherry}
Was able to remove watermellon from fruitBag.
fruitBag after removing watermelon
n=6 Bag: {Pear}, {Plum}, {Mango}, {Apple}, {Nectarine}, {Cherry}
fruitBag before removing nectarine
n=6 Bag: {Pear}, {Plum}, {Mango}, {Apple}, {Nectarine}, {Cherry}
Was able to remove nectarine from fruitBag.
fruitBag after removing nectarine
n=5 Bag: {Pear}, {Plum}, {Mango}, {Apple}, {Cherry}
Sample run WITH a..z order (extra credit)
fruitBag upon startup
2
CSIT254 Programming Lab 4 – Linked Lists
n=0 Bag: size is 0, therefore assumed Empty
added Pear… Size: 1
added Plum… Size: 2
added Watermellon… Size: 3
added Mango…
Size: 4
added Apple… Size: 5
added Nectarine… Size: 6
added Cherry…
Size: 7
fruitBag after 7 adds
n=7 Bag: {Apple}, {Cherry}, {Mango}, {Nectarine}, {Pear}, {Plum}, {Watermellon}
No! No banana in the fruitBag
Yes! There is a nectarine in the fruitBag!
Yes! There is a watermellon in the fruitBag!
fruitBag before removing banana
n=7 Bag: {Apple}, {Cherry}, {Mango}, {Nectarine}, {Pear}, {Plum}, {Watermellon}
Sorry! unable to remove banana from fruitBag!
fruitBag after removing banana
n=7 Bag: {Apple}, {Cherry}, {Mango}, {Nectarine}, {Pear}, {Plum}, {Watermellon}
fruitBag before removing watermellon
n=7 Bag: {Apple}, {Cherry}, {Mango}, {Nectarine}, {Pear}, {Plum}, {Watermellon}
Was able to remove watermellon from fruitBag.
fruitBag after removing watermellon
n=6 Bag: {Apple}, {Cherry}, {Mango}, {Nectarine}, {Pear}, {Plum}
fruitBag before removing nectarine
n=6 Bag: {Apple}, {Cherry}, {Mango}, {Nectarine}, {Pear}, {Plum}
Was able to remove nectarine from fruitBag.
fruitBag after removing nectarine
n=5 Bag: {Apple}, {Cherry}, {Mango}, {Pear}, {Plum}
UML
UML for IntNode
IntNode
-data:int
-link: IntNode
+IntNode( initialData: int, initialLink:IntNode )
3
CSIT254 Programming Lab 4 – Linked Lists
+ getData( ):int
+ getLink( ):IntNode
+ setData( newData:int ):void
+ setLink( newLink :IntNode ):void
UML for IntLinkedBag
IntLinkedBag
-head: IntNode
-tail: IntNode
-numElements:int
+ IntLinkedBag( )
+ getSize( ):int
+ add( element : int ):void
+ exists( target: int ): boolean
+ countOccurences( target:int ):int
+ remove( target: int ): boolean
+ iteratorPrototype():ListerPrototype2
4

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper
Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER