This assignment makes use of the files contained in this zip file.This assignment is based on the material from Sections 5.5 and 5.6 from the course textbook.Create a (parameterized) class WeirdArrayr Create a WeirdIterator Your WeirdIterator In the definition of your WeirdArray T[] theArray = new T[n];when T is a type parameter. The declaration T[] theArray is not the problem, the problem is with the creation of the array (using new). You get around this limitation by creating an array of type ObjectObject[] theArray = new Object[n];and then using a cast when a method needs to return an element from within the array. The resulting code will work correctly, but unfortunately the compiler will complain about it by issuing warnings of unchecked casts. This is one of the few places in your generic code where it is OK to use the @SuppressWarnings(unchecked) annotation.In the zip file there is a program TestIterator.java that tests your implementations of the WeirdArray When you have WeirdArray In the zip file there is a program TestIterator_2.java that tests your implementation of the WeirdIterator2 The reason for designing two iterators is to help you understand why the Java designers created the Iterable and Iterator interfaces the way they did. At first, it would seem more natural to have the hasNext() and next() methods in the Iterable interface so that an iterable collection would know how to iterate through itself. But then there could be only one way to iterate through a specific collection (like WeirdAray), the way built into the collection.By having the iterator() method of the Iterable interface return an Iterator object, and then having the hasNext() and next() methods in the Iterator interface, it is possible to separate the way you iterate through a container from the container itself. In fact, you can even design an Iterator for a container that is not Iterable (how?). When a container is Iterable, what that really means is that the container has a preferred way to be iterated (using the Iterator returned by the iterator() method). But if we need to, we can define multiple other ways to iterate through the container type by defining multiple Iterator classes that all take the specific container class in their constructors.Turn in a zip file called CS275Hw5Surname.zip (where Surname is your last name) containing your versions of WeirdArray.java, WeirdIterator.java, and WeirdIterator2.java.
Programming
[Solved] SOLVED:Programming Assignment 5
$25
File Name: SOLVED:Programming_Assignment_5.zip
File Size: 292.02 KB
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.