L03a

Due by the end of this meeting

Starter Files:


SUBMIT   /   Submission Summary

Review of CSCI 1228

Activity 1
Consider the program ListManipulations from the sample code (provided). Complete the method printListForEach using a for-each loop.

Note: the output should look just like the output from the printListWithIterator method. That is:

Printing the list using a for-each loop. BEEEEEP! Fifty BEEEEEP! BEEEEEP! ten Thirty twenty twenty ...press enter... Printing the list using a list iterator. BEEEEEP! Fifty BEEEEEP! BEEEEEP! ten Thirty twenty twenty ...press enter...

You might want to see how that method goes about making sure that there are four words per line and each word right-justified in its column.

Activity 2
Create a class named TakeFiveProg. Give it a method called takeFive that takes a List of any type and returns a List of the same type consisting of the first five elements of the given List. Those five items are removed from the given List.

Test your method using the following code:

List<Character> letters = new ArrayList<>(); char[] characters = "nevertheless it moves".toCharArray(); for (char letter : characters) { letters.add(letter); } System.out.println("Before: " + letters); List<Character> taken = takeFive(letters); System.out.println("Taken: " + taken); System.out.println("Remaining: " + letters);

You should get the following output:

Before: [n, e, v, e, r, t, h, e, l, e, s, s, , i, t, , m, o, v, e, s] Taken: [n, e, v, e, r] Remaining: [t, h, e, l, e, s, s, , i, t, , m, o, v, e, s]
Submit your data type classes by the end of this recitation. (You do not need to submit your testing code; we know what your code is supposed to do!)

Your grade will be based on the following rubric:

Submit this/these files:


SUBMIT   /   Submission Summary