Question: It's in Java and I can only code in Python. Problem No.1 is writing Junits for the methods and Problem No.2 is implementing the methods

It's in Java and I can only code in Python.
Problem No.1 is writing Junits for the methods and Problem No.2 is implementing the methods in the given code.
It's in Java and I can only code in Python. Problem No.1
is writing Junits for the methods and Problem No.2 is implementing the
methods in the given code. 1. (30 points) Write JUnit test cases

1. (30 points) Write JUnit test cases for the following list methods: (a) A method most common which assumes the list is organized so that duplicate values are together. (For example, it could be sorted.) The method returns the value that appears the most times. When more than one value appears the most number of times, the first occurring such value is returned. If the list is empty, the method throws a NoSuchElementException. (b) A method doubleIt that takes no arguments and adds a duplicate of each list element after its original occurrence. (It's actually creating duplicate references. For example, calling this method on the list ("a", "b", "c", "d") changes it to ("a", "a", "b", "b", "c", "c", "d", "d"). (c) A method moveToTail that takes an index. It should move the value at that index to the "tail" of the list, i.e. so that it's the last element. For example, calling the method with argument 2 on the list ("a", "b", "c", "d") changes the list to ("a", "b", "d", "c"). If the index is invalid, the method should throw an IndexOutOf BoundsException. You can build off the given code, other code we/you have written this term, and code from the text. I suggest that you use the code from HW 3, either the original given code or your HW submission. Be sure to use these test cases on the implementations you create for the problems below. 2. (30 points) Implement each of the methods above for an array-based list. 3. (30 points) Implement each of the methods from problem 1 for a linked-memory list implementation. public class MyArrayList implements MyList= num)) throw new IndexOutOfBoundsException(); return vals[index]; public class MyLinkedListT> implements MyList private Node head; public class Node public T value; public Node next; public Node(t value, Node next) { this.value-value; this.next next; public MyLinkedlist() { head - null; public void addFront (T newitem) { Node newlode - new Node(newitem, head); head - nowode: public boolean contains(TS) //returns whether the list contains Node curr - head; while(curr ! - null) { if(curr.value.equals(s)) return true; curr - curr.next; return false; public int size() { Node curr - head; int count - @; while(curr - null) { count : curr - curr.next; return count: public boolean remove(t val) { //removes first occurrence of val from the list //returns whether it was there Node curr - head; //current Node we're looking at Node prev - null; // Node before that one while(curr ! - null) { if(curr.value.equals(val)) { if(curr -- head) head - curr.next; //special case for removing head else prev.next - curr.next; /remove curr's node return true; prev - curr: curr - curr.next; return false; //didn't find val @Override public void add(t todd) if(head = null) addFront(toAdd): return; Node curr - head; while(curr.next !- null) //advance curr to point at first node curr - curr.next; curr.next - new Mode(todd, null); adverride public T Rat(int index) // TODO Auto-generated method stub return null

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!