Question: this is the fourth part here the link for the first part of the question: https://www.chegg.com/homework-help/questions-and-answers/please-notice-part-one-rest-question-posted-different-post-object-oriented-programming-inh-q70115587 here the link for the second part of the

this is the fourth part

here the link for the first part of the question: https://www.chegg.com/homework-help/questions-and-answers/please-notice-part-one-rest-question-posted-different-post-object-oriented-programming-inh-q70115587

here the link for the second part of the question: https://www.chegg.com/homework-help/questions-and-answers/second-part-link-first-part-question-https-wwwcheggcom-homework-help-questions-answers-ple-q70115962

here the link for the third part of the question: https://www.chegg.com/homework-help/questions-and-answers/thirdpart-link-first-part-question-https-wwwcheggcom-homework-help-questions-answers-pleas-q70116269

______________________ _________________________

import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail;

import org.junit.jupiter.api.Test;

class UniqueListTest {

@Test void testInheritance() { IntegerList list = new UniqueList(); assertTrue(list instanceof IntegerList); assertTrue(list instanceof UniqueList); } @Test void testConstructors() { IntegerList list = new UniqueList(); assertEquals(0, list.size()); assertEquals("[]", list.toString()); try { list = new UniqueList(1); fail(); } catch (IllegalArgumentException e) { assertEquals("The capacity cannot be less than 2.", e.getMessage()); } list = new UniqueList(3); assertEquals(0, list.size()); assertEquals("[]", list.toString()); } @Test void testAdd() { IntegerList list = new UniqueList(); assertEquals(0, list.size()); assertEquals("[]", list.toString()); list.add(5); assertEquals(1, list.size()); assertEquals(5, list.get(0)); assertEquals("[5]", list.toString()); try { list.add(5); fail(); } catch (IllegalArgumentException e) { assertEquals("The integer 5 is already in the list.", e.getMessage()); } assertEquals(1, list.size()); assertEquals(5, list.get(0)); assertEquals("[5]", list.toString()); list.add(6); assertEquals(2, list.size()); assertEquals(5, list.get(0)); assertEquals(6, list.get(1)); assertEquals("[5, 6]", list.toString()); list.add(7); assertEquals(3, list.size()); assertEquals(5, list.get(0)); assertEquals(6, list.get(1)); assertEquals(7, list.get(2)); assertEquals("[5, 6, 7]", list.toString()); try { list.add(6); fail(); } catch (IllegalArgumentException e) { assertEquals("The integer 6 is already in the list.", e.getMessage()); } assertEquals(3, list.size()); assertEquals(5, list.get(0)); assertEquals(6, list.get(1)); assertEquals(7, list.get(2)); assertEquals("[5, 6, 7]", list.toString()); } @Test void testInsert() { IntegerList list = new UniqueList(); assertEquals(0, list.size()); assertEquals("[]", list.toString()); list.insert(0, 7); assertEquals(1, list.size()); assertEquals(7, list.get(0)); assertEquals("[7]", list.toString()); list.insert(0, 5); assertEquals(2, list.size()); assertEquals(5, list.get(0)); assertEquals(7, list.get(1)); assertEquals("[5, 7]", list.toString()); try { list.insert(1, 7); fail(); } catch (IllegalArgumentException e) { assertEquals("The integer 7 is already in the list.", e.getMessage()); } assertEquals(2, list.size()); assertEquals(5, list.get(0)); assertEquals(7, list.get(1)); assertEquals("[5, 7]", list.toString()); list.insert(1, 6); assertEquals(3, list.size()); assertEquals(5, list.get(0)); assertEquals(6, list.get(1)); assertEquals(7, list.get(2)); assertEquals("[5, 6, 7]", list.toString()); try { list.insert(4, 8); fail(); } catch (IndexOutOfBoundsException e) { assertEquals("The index is outside the range [0, 3].", e.getMessage()); } assertEquals(3, list.size()); assertEquals(5, list.get(0)); assertEquals(6, list.get(1)); assertEquals(7, list.get(2));

_______________

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!