Assignment 1: Mylist Ball Node Value #Next - Node Null Ball

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Assignment 1

You will need four classes:

1. MyList class, which represents the linked list of Ball objects.

2. Node class, containing a value as a Ball object and a link to the #next_node, set


as null by default.

3. Ball class, containing a maker as String and a radius as integer, for example, a


ball has information about the maker and the radius as (C, 15).

4. Main for testing the following the methos.

Build the following methods in your linked list class:

1. addLast(value) adds a new node containing value to the end of the list

2. addFirst(value) adds a new node containing value to the start of the list

3. size returns the total number of nodes in the list

4. at(index) returns the node at the given index

5. pop removes the last element from the list

6. find(value) returns the node containing value, or null if not found.

7. addBefore(xnode, value) adds a new node containing value before xnode.

8. traverse print your Linked List out. The format should be: ( value ) -> ( value )
-> ( value ) -> null

9. sort sorts the first 4 elements descendingly by the radius.

10. removeSecondMax removes the second element having maximum radius from the
list.

You might also like