Modify the class LinkedList given in the lecture by adding to it the functions l
ID: 3536634 • Letter: M
Question
Modify the class LinkedList given in the lecture by adding to it the functions listed below for Exercise 2. In each case, the appropriate error message should be generated if an invalid condition occurs.
a. toString(): modify the display function to overload the toString function of the Object class.
b. int length(): create this function to determine the number of items in the list (accessor function).
c. void clear(): create this function to remove all of the items from the list. After this operation is completed, the length of the list is zero.
d. void insertEnd(int item): create this function to insert item at the end of the list.
e. void replace(int location, int item): create this function to replace the item in the list at the position specified by location. The item should be replaced with item.
f. int get(int location): create a function that returns the element at the position location.
Exercise 3: Using a Linked List
This exercise is similar to Exercise 3 in Lab 2, but uses the LinkedList class implemented in Exercise 2 above. That is, using the class LinkedList, write a program that uses it to store 100 random numbers. Again, consider that each of these random numbers is an integer in the interval [0, 200]. Write the program in such a way that there are no number duplicates.
Explanation / Answer
ANSWER
Van Object {
fName: Dodge
fNumDoors: 4
fYearManufactured: Thu Sep 30 19:16:14 EDT 2004
fColor: Blue
fOptions: [Air Conditioning, Leather Interior]
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.