Apr 19: Collections Lab CS 159: Advanced Programming James Madison University, Spring 2022 Apr 19: Collections Lab Lesson Outline 10 min P5 Debrief * Avoiding duplicate code * Submitting 1-2 days late 15 min Mini Lecture * java.util.Iterator / java.lang.Iterable * Card.java / Deck.java / Main.java * IteratorDemo.java working with collections * How to update a collection using an iterator 50 min Lab Activity * See instructions below; submit by 11:00pm Before Thursday Textbook: Read the following sections: 15.1 Collections 15.2 Linked Lists 15.3 Sets 15.4 Maps Homework: Watch for Project 6 (coming soon...) Collections Lab Introduction Your goal in this lab is to complete the unfinished methods: CollectionExercises.java The Gradescope JUnit tests are provided for your convenience: CollectionExercisesTest.java For each method, you should first take a minute to think about the problem in order to select an appropriate collection type (or types) to use in your solution. The following documentation might be helpful. Collection ArrayList HashSet HashMap You should take full advantage of the functionality provided by the collection classes to make your solutions as concise and efficient as possible. For example, the Collection interface provides an addAll method that makes it possible to add all of the elements of one collection to another using a single method call. Where appropriate, you should use that method rather than creating a loop that repeatedly calls the add method. Your solutions for these exercises must satisfy the following requirements: You may not use indexed for loops. Use only for-each loops or iterators, as appropriate. None of your methods may include nested loops. Nested loops generally take a long time to iterate over large collections. (You will look at this more formally in CS 240). Submitting Submit your completed file to Gradescope. You may submit as many times as you like.