Problem

Suppose you have an IntegerList class that is an ordered mutable collection of (not-necess...

Suppose you have an IntegerList class that is an ordered mutable collection of (not-necessarily-unique) integers.  Suppose it has only the following methods:

void cons(int x)  //adds x to the front of this list	int first() //returns the first integer in this list	int second() //returns the second integer in this list	int third() //returns the third integer in this list	int nth(int n) //returns the n-th integer in this list	IntegerList rest() //returns a new list identical to this list				// except that the first integer of this list is omitted	int size() //returns the length of the list (number of elements)

Assume that first, second, third, and nth, respectively, throw an Exception if there is no first, second, third, or n-th integer, respectively, in the list.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 5
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT