Question

Revise SimpleLinkedListTest Revise the file SimpleLinkedListTest.java given in the lecture in the following ways: Create and...

Revise SimpleLinkedListTest

Revise the file SimpleLinkedListTest.java given in the lecture in the following ways:

  • Create and populate a single linked list int values

  • Use this list to test each method you implement in the following ways

    o Haveatleast1testcaseforsuccessfulcallingthetestedmethod
    o Haveatleast1testcaseforunsuccessfulcallingthetestedmethod.Forexamplecallingthemethod

    public int get(int index) and passing an invalid index.

  • NOTE: since the code here is mainly for testing purpose, you do NOT HAVE to use the user input when

    populating the list and testing your methods.

---------CODE SImpleLinkedListTest------------

package 1234;


public class SimpleLinkedListTest {

public static void main(String[] args) {
  
SimpleLinkedList numbers = new SimpleLinkedList();
  
  
numbers.add(10);
numbers.add(20);
numbers.add(30);
  

System.out.println(numbers.toString());
  
//System.out.println(numbers);
}   
  
}

Homework Answers

Answer #1

1. Original List

2. Successful calling of the method:

3. Unsuccessful (invalid Test case)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I have a 2 class code and it works everything is fine and runs as it...
I have a 2 class code and it works everything is fine and runs as it supposed too. What will the UML be for both classes. Here's the code, any help will be awsome, Thanks. import java.util.Scanner; public class PayRollDemo { public static void main(String[] args) { double payRate; int hours; PayRoll pr = new PayRoll(); Scanner keyboard = new Scanner(System.in); for (int index = 0; index < 7 ; index++ ) { System.out.println(); System.out.println("EmployeeID:" + pr.getEmployeeID(index)); System.out.println(); System.out.println("Enter the...
PP 8.2 Modify the program from PP 8.1 so that it works for numbers in the...
PP 8.2 Modify the program from PP 8.1 so that it works for numbers in the range between −25 and 25 THIS IS MY CODE! please edit this...Thank you import java.util.Scanner; public class Array { public static void main (String[] args) { Scanner scan = new Scanner (System.in); int[] integs = new int[51]; System.out.println("Enter integers 0-50 [enter -1 to quit]: "); int nums = scan.nextInt(); while (nums != -1 && nums>=0 && nums<=50) { integs[nums]++; nums = scan.nextInt(); } for...
I need a method for public void ****************** write the method “insertDoubles” that for each value...
I need a method for public void ****************** write the method “insertDoubles” that for each value found in an integer linked list it inserts that value doubled after the original. The method should return nothing and take in in no parameters. If the list is empty, then the method should do nothing. To avoid infinite loops you need to move the iterator past the newly inserted value. here is the provided code public class Question02 { public class ListNode//public for...
Modify the following code by JAVA language Write a static method totalDurations that is passed the...
Modify the following code by JAVA language Write a static method totalDurations that is passed the parallel arrays from the main program. It creates a new pair of parallel arrays (phone numbers and durations, again) where each different incoming phone number is stored exactly once, and the duration is the total duration of all the calls from that phone number. It then prints these arrays. Nothing is returned. For example, if the arrays contain 555-1234 (duration 10), 555-4321 (duration 20),...
Covert the following Java program to a Python program: import java.util.Scanner; /** * Displays the average...
Covert the following Java program to a Python program: import java.util.Scanner; /** * Displays the average of a set of numbers */ public class AverageValue { public static void main(String[] args) { final int SENTINEL = 0; int newValue; int numValues = 0;                         int sumOfValues = 0; double avg; Scanner input = new Scanner(System.in); /* Get a set of numbers from user */ System.out.println("Calculate Average Program"); System.out.print("Enter a value (" + SENTINEL + " to quit): "); newValue =...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as possible: What is a checked exception, and what is an unchecked exception? What is NullPointerException? Which of the following statements (if any) will throw an exception? If no exception is thrown, what is the output? 1: System.out.println( 1 / 0 ); 2: System.out.println( 1.0 / 0 ); Point out the problem in the following code. Does the code throw any exceptions? 1: long value...
You are given a reference to the head node of a linked list that stores integers....
You are given a reference to the head node of a linked list that stores integers. Please print the minimum element in this linked list. The class ListNode.java contains the description of a single node in the linked list. It has a num field to store the integer number and a reference next that points to the next element in the list. The file MyList.class is a pre-defined java code, that creates a linked list. The file ListSmallest.java creates an...
[Java] I'm not sure how to implement the code. Please check my code at the bottom....
[Java] I'm not sure how to implement the code. Please check my code at the bottom. In this problem you will write several static methods to work with arrays and ArrayLists. Remember that a static method does not work on the instance variables of the class. All the data needed is provided in the parameters. Call the class Util. Notice how the methods are invoked in UtilTester. public static int min(int[] array) gets the minimum value in the array public...
The following program creates a linked list which contains 5 links. Add a method called doubleValue()...
The following program creates a linked list which contains 5 links. Add a method called doubleValue() to the LinkedList class. The doubleValue() method must double the value of the number data field in each link. Add the required code to the main() method to call the doubleValue() method and display the revised list. public class Link { private int number; private Link next;      public Link(int x) { number = x; }    public void displayLink() { System.out.println("The number is:...
The following program creates a linked list which contains 5 links. Add a method called doubleValue()...
The following program creates a linked list which contains 5 links. Add a method called doubleValue() to the LinkedList class. The doubleValue() method must double the value of the number data field in each link. Add the required code to the main() method to call the doubleValue() method and display the revised list. public class Link { private int number; private Link next;      public Link(int x) { number = x; }    public void displayLink() { System.out.println("The number is:...