Question: package hw6; import java.util.NoSuchElementException; public class MyList { private class MyListNode { public Item item; public MyListNode next; public MyListNode(Item i, MyListNode n) { item

package hw6;

import java.util.NoSuchElementException;

public class MyList { private class MyListNode { public Item item; public MyListNode next; public MyListNode(Item i, MyListNode n) { item = i; next = n; } } private MyListNode first; /** * Creates an empty list. */ public MyList() { first = null; } /** * Inserts an item at the front of the list * * @param item the item to be inserted */ public void insertAtFront(Item item) { MyListNode node = new MyListNode(item, first); first = node; } /** * Returns the number of items equal to {@code target} in the list * * @param target the data item to count * @return the number of times {@code target} appears in the list */ public int count(Item target) { // TODO return -1; }

/** * Returns the data in position {@code index} in the list. * Note that like arrays the first data item is in position 0. * @param index the index of the item to get from the list * @throws NoSuchElementException if the list doesn't have a * position {@code index} * @return the data in position {@code index} in the list. */ public Item get(int index) { // TODO return null; }

/** * Constructs a separate copy of a list. Changes to the copy do not affect the original. * @return a copy of the list */ public MyList copy() { // TODO return null; }

/** * Constructs a {@code String} representation of the list. The {@code String} * is a comma separated listing of the {@code String} representations of the items * in the same order they appear in the list. There are no spaces between items. * @return a {@code String} representation of the list. */ public String convertToString() { // TODO return null; } /** * Deletes the first occurrence of {@code target} from the list if it is present. * Does nothing if {@code target} is not present. * * @param target the item to be deleted */ public void delete(Item target) { //TODO } }

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!