Implement MyLinkedList) The implementations of the methods contains(E e), get(int index), indexOf(E e), lastIndexOf(E e), and set(int index, E e) are omitted in the MyLinkedList class. Implement these methods. Define a new class named MyLinkedListExtra that extends MyLinkedList to override these methods. Test your new MyList class using the code at import java.util.*; public class Exercise24_02 { public static void main(String[] args) { new Exercise24_02(); } public Exercise24_02() { String[] names = {"Tom", "Susan", "Kim", "George", "Peter", "Jean", "George", "Jane", "Denise", "Jenny", "Susan", "Kathy", "Jane"}; MyList list = new MyLinkedListExtra<>(names); System.out.println(list); Scanner input = new Scanner(System.in); System.out.print("Enter a name: "); String name = input.next(); System.out.print("Enter an index: "); int index = input.nextInt(); System.out.println(name + " is in the list? " + list.contains(name)); System.out.println("name at index " + index + " is " + list.get(3)); System.out.println(name + " is at index " + list.indexOf(name)); System.out.println(name + " is at last index " + list.lastIndexOf(name)); list.set(index, name); } } class MyLinkedListExtra extends MyLinkedList { /** Create an empty list */ public MyLinkedListExtra() { // Implement } /** Create a list from an array of objects */ public MyLinkedListExtra(E[] objects) { // Implement } @Override /** Return true if this list contains the element e */ public boolean contains(Object o) { // Implement } @Override /** Return the element from this list at the specified index */ public E get(int index) { // Implement } @Override /** Returns the index of the first matching element in this list. * Returns -1 if no match. */ public int indexOf(Object o) { // Implement } @Override /** Returns the index of the last matching element in this list * Returns -1 if no match. */ public int lastIndexOf(Object o) { // Implement } @Override /** Replace the element at the specified position in this list * with the specified element. */ public E set(int index, E e) { // Implement } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

(Implement MyLinkedList) The implementations of the methods contains(E 
e), get(int index), indexOf(E e), lastIndexOf(E e), and set(int 
index, E e) are omitted in the MyLinkedList class. Implement these methods. 
Define a new class named MyLinkedListExtra that extends MyLinkedList
to override these methods. Test your new MyList class using the code at 

import java.util.*;

public class Exercise24_02 {
  public static void main(String[] args) {
    new Exercise24_02();
  }

  public Exercise24_02() {
    String[] names = {"Tom", "Susan", "Kim", "George", "Peter", 
        "Jean", "George", "Jane", "Denise", "Jenny", "Susan", "Kathy", "Jane"};
    MyList<String> list = new MyLinkedListExtra<>(names);   

    System.out.println(list);
    Scanner input = new Scanner(System.in);
    System.out.print("Enter a name: ");
    String name = input.next();
    
    System.out.print("Enter an index: ");
    int index = input.nextInt();
    
    System.out.println(name + " is in the list? " + list.contains(name));
    System.out.println("name at index " + index + " is " + list.get(3));
    System.out.println(name + " is at index " + list.indexOf(name));
    System.out.println(name + " is at last index " + list.lastIndexOf(name));
    list.set(index, name);
  }
}

class MyLinkedListExtra<E> extends MyLinkedList<E> {
  /** Create an empty list */
  public MyLinkedListExtra() {
    // Implement
  }

  /** Create a list from an array of objects */
  public MyLinkedListExtra(E[] objects) {
    // Implement
  }

  @Override /** Return true if this list contains the element e */
  public boolean contains(Object o) {
    // Implement
  }

  @Override /** Return the element from this list at the specified index */
  public E get(int index) {
    // Implement
  }

  @Override /** Returns the index of the first matching element in this list.
   *  Returns -1 if no match. */
  public int indexOf(Object o) {
    // Implement
  }

  @Override /** Returns the index of the last matching element in this list
   *  Returns -1 if no match. */
  public int lastIndexOf(Object o) {
    // Implement
  }

  @Override /** Replace the element at the specified position in this list
   *  with the specified element. */
  public E set(int index, E e) {
    // Implement
  }
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY