Package algs13

Class MyListAccessor


public class MyListAccessor extends Object
MyListAccessor (debugging).

This homework is intended to give you hands-on experience debugging and testing code. The intent is to give you more practice with linked lists and develop your intuition about how linked lists work.


1. Make sure you have watched last week's lecture. Read over the main method and the test methods to develop an understanding of what they are doing.

2. Look for the TODO in the code below.

3. Utilize the techniques presented (your choice of Inspection, print statements, trace on paper, Trace utility, or IntelliJ Interactive debugger) to find and fix the bugs.

This is a "written homework" assignment. You do NOT need to submit this file with solutions as part of this homework. You DO need to submit your answers to the questions posed below.

  • Constructor Details

  • Method Details

    • numFives1

      public int numFives1()
    • numFives2

      public int numFives2()
    • numFives3

      public int numFives3()
    • numFives4

      public int numFives4()
    • numFives5

      public int numFives5()
    • numFives6

      public int numFives6()
    • numFives7

      public int numFives7()
    • numFives8

      public int numFives8()
    • numFives9

      public int numFives9()
    • numFives10

      public int numFives10()
    • numFives

      public static int numFives(MyListAccessor list)
      TODO: Change this to invoke each method, numFives1, numFives2, ... numFives10, in turn. You can comment out the first line and uncomment the second line.

      For each version of the method, tell me:

      a. Whether there is a bug or not. (Note: There are no compiler errors in this file). b. What's wrong with the method and how to fix it.

      Fix the code for each method to make it work. Some of the implementations may end up looking the same, or very similar.

      Write your answers the the questions about each implementation of numFives on paper, or put them in a Word document. Upload a scan of your handwritten answers or your Word document to D2L. Do not submit image files directly, although you can paste photographs of your handwritten answers into the Word document. A better alternative would be to use a scanning app on your phone, and submit a PDF of your handwritten answers.

      You do not need to hand in this file.

    • main

      public static void main(String[] args)
    • toString

      public String toString()
      toString in class Object