just follow the question

Question Description

Lab 4: 30 pts

The main new components in this lab are discussed in Chapter 3’s section on singly linked lists and were reviewed in class.

IMPORTANT: This lab builds on Lab 3, so if you didn’t do it, then complete Lab 3 as a part of this lab, but see next comment on GRADING to understand how that works.

GRADING: I won’t be deducting points if you didn’t do parts of the Lab 3 piece correctly.

I will only be grading your implementation of the Linked List and how you use it and the player move count.

  1. SUMMARY
  1. Add to Lab 3 by tracking the player’s moves in a linked list. Then, before printing out the maze at the end, cycle through all the nodes of the linked list and change the cell value of each grid spot where the user has been to a number like 8 or 5 or 3 or any integer other than 0 or 1. This way the grid print out at the end will show the player’s path.
  1. Secondly, track the number of moves the player makes and print that out at the end as well.
  1. This lab will involve the following new features:
    1. Singly Linked List
  1. DETAILS
  1. There won’t be as much detail on the singly linked list since we went over an implementation in class.
  1. Classes and Adjustments to Lab 3.
  1. Node – This is a new class that needs to be added to Lab 3.
    1. Instance variables:
      1. xPosition – int type.
      2. yPosition – int type.
      3. nextNode – Node type.
  2. LinkedList – This class will hold the linked list.
    1. Instance variables:
      1. headNode – Node type.
    2. Methods:
      1. addHeadNode
        1. Takes in two parameters, x and y, which are integer types.
        2. Returns nothing.
        3. With the x and y params, it creates a new node object and sets the nextNode on the new node object to the existing headNode object.
        4. It then assigns this new node object to the headNode variable.
      2. removeHeadNode
        1. Takes in no parameters.
        2. This is tricky so you need to carefully think through how to do this, but the following is what it needs to accomplish:
          1. It needs to change the current head node to the node that is in the head node’s nextNode variable; and it needs to return that previous head node to the method caller.
          2. Essentially, you’re taking the head node out of the linked list and returning it and setting the next node in line as the new head node.
  1. Updating run method in GameGrid class.
    1. You need to instantiate a LinkedList instance.
    2. In the while loop, use the iUserRow and iUserCol values to call the addHeadNode method on the LinkedList instance to add a node for every user move.
    3. Create second while loop: AFTER the existing while loop exits but BEFORE the grid print out.
      1. This loop will run until all LinkedList nodes have been processed.
      2. In the loop, call the removeHeadNode method on the LinkedList instance and use the returned node’s xPosition and yPosition to update the grid at that position with any number you choose besides 0 and 1.
      3. You can also use this loop to count the number of player moves.
    4. Print out the total number of player moves at the end when printing the grid.

Get your college paper done by experts

Do my question How much will it cost?

Place an order in 3 easy steps. Takes less than 5 mins.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *