Lab 4:
1) Using the Sequence ADT
sentence.insertFirst("This ");
sentence.insertLast("sentence.");
===> "This sentence."
printSentence( sentence );
> java Sentence
--------------------------------------------------------------------------------
This sentence.
This sample dumb sentence.
This dumb sample sentence.
This is a sample sentence.
This is a sentence.
This is a self-referential sentence.
The sentence is now empty.
Let's end by throwing an exception:
Exception in thread "main" InvalidPositionException: Position does not belong to
a valid NodeList
at NodeList.checkPosition(NodeList.java:31)
at NodeSequence.rankOf(NodeSequence.java:34)
at Sentence.main(Sentence.java:56)
--------------------------------------------------------------------------------
2) Recursion:
- Try the game first. here
- The recursive pseudo code for the solution. here
- The java class for the solution. here
- Test class with 5 disks to be moved from 1 to 3 using 2.
Extra
3) Exercise 5.7 from your text book. Sequence ADT extension