Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA HELP!!! Please help me with this Java problem, thank you! List.java https://cs1331.gitlab.io/fall2018/hw5/List.java List Introduction In this homework assignment, you will be exploring the implementation

JAVA HELP!!! Please help me with this Java problem, thank you!

image text in transcribedimage text in transcribedimage text in transcribed

List.java https://cs1331.gitlab.io/fall2018/hw5/List.java

List Introduction In this homework assignment, you will be exploring the implementation of interfaces. You can think of an interface as a skeleton for a type of object; interfaces give method signatures that must be implemented in any class, which implements the interface. Click this link to learn more about interfaces https://docs.oracle.com/javase/tutorial/java/landl/createinterface.html Remember to refer to the Java API if you are struggling with the concept of interfaces: https://docs.oracle.com/javase/10/docs/api/overview-summary.html Problem Description You will be implementing the methods from the interface, List, into the concrete class, MyList. You will also be using IllegalArgumentException and IndexoutofBoundsException. Make sure to check Piazza for updates. There will not be announcements about clarifications on homeworks, List This interface is already written and provided for you: List.java It has the following fields: int INITIAL_CAPACITY Represents the default initial capacity of our list. It has the following methods: void add(E e) Adds the passed-in element to the last position in the list and throws an IllegalArgumentException if e is null. Consider how you can store this list and the possible problems to account for when using this. E get(int index) Selects an element from the given index in the list. void replace(E e, E replacewith) Replaces all instances of e with replacewith in the list. This method throws an IllegalArgumentException if either of the passed-in elements are null. int remove(E e) Removes all instances of e and returns a count of how many instances were removed. The method throws an IllegalArgumentException if e is null. This method should also be ensuring that null elements are not left in the middle of the list. For example, if there is {1, 2, 3} and remove(2) s called then the list should not become {1, null, 3} int contains (E e) Checks to see how many instances of e are in the list and returns this count. The method throws an IllegalArgumentException if e is null. boolean isEmpty() Checks to see if there are any objects in the list. If there is at least one object, then this should return true. Otherwise, this should return false. void clear() Should make the entire List empty; all objects are removed from the list. * int size) Returns the number of non-null elements in the list. El] toArray (E[] e). Returns the array e that was input. e should be filled with as many non null elements of the list as it can fit, starting from the beginning of the list (e.g. if e is length 3 and the list is (1,2,3,4,5), e should be returned as '11,2,31). Any extra spots in e should be set to null List Introduction In this homework assignment, you will be exploring the implementation of interfaces. You can think of an interface as a skeleton for a type of object; interfaces give method signatures that must be implemented in any class, which implements the interface. Click this link to learn more about interfaces https://docs.oracle.com/javase/tutorial/java/landl/createinterface.html Remember to refer to the Java API if you are struggling with the concept of interfaces: https://docs.oracle.com/javase/10/docs/api/overview-summary.html Problem Description You will be implementing the methods from the interface, List, into the concrete class, MyList. You will also be using IllegalArgumentException and IndexoutofBoundsException. Make sure to check Piazza for updates. There will not be announcements about clarifications on homeworks, List This interface is already written and provided for you: List.java It has the following fields: int INITIAL_CAPACITY Represents the default initial capacity of our list. It has the following methods: void add(E e) Adds the passed-in element to the last position in the list and throws an IllegalArgumentException if e is null. Consider how you can store this list and the possible problems to account for when using this. E get(int index) Selects an element from the given index in the list. void replace(E e, E replacewith) Replaces all instances of e with replacewith in the list. This method throws an IllegalArgumentException if either of the passed-in elements are null. int remove(E e) Removes all instances of e and returns a count of how many instances were removed. The method throws an IllegalArgumentException if e is null. This method should also be ensuring that null elements are not left in the middle of the list. For example, if there is {1, 2, 3} and remove(2) s called then the list should not become {1, null, 3} int contains (E e) Checks to see how many instances of e are in the list and returns this count. The method throws an IllegalArgumentException if e is null. boolean isEmpty() Checks to see if there are any objects in the list. If there is at least one object, then this should return true. Otherwise, this should return false. void clear() Should make the entire List empty; all objects are removed from the list. * int size) Returns the number of non-null elements in the list. El] toArray (E[] e). Returns the array e that was input. e should be filled with as many non null elements of the list as it can fit, starting from the beginning of the list (e.g. if e is length 3 and the list is (1,2,3,4,5), e should be returned as '11,2,31). Any extra spots in e should be set to null

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started