Problem Description
Assassins is a live-action game in which players try to eliminate each other using mock weapons in an effort to become the last surviving player.
This game is popular on college campuses and is played by thousands of students all over the world. Game hosts start a round by assigning each player a unique target. Every player has target and are themselves a target for someone else. When a player eliminates a target, usually by marking them with a pen or some tape, they get their victims target. The game ends when there is only one player remaining.
This sort of behavior can be modeled with a linked list! To be exact, this scenario requires a circularly linked list (as every player has a target and is a target), but for the sake of this homework we will ONLY be asking you to implement a regular doubly linked list.
Solution Description
Fill out the class called MyLinkedList.java that contains your doubly linked list implementation. We have provided an interface, SimpleList.java, that MyLinkedList.java must implement. Look at the descriptions in SimpleList.java to understand what each method requires. You may create additional methods and fields for your linked list as needed.
Your linked list must use the provided Node inner class to implement the list, and must update both the head and tail fields when appropriate.
Testing
For this assignment you will be expected to rigorously test your linked list implementation. We encourage you to write your own tester class and test various edge cases. Here is an example tester class:
public class Test { public static void main(String[] args){MyLinkedList<Integer> mll = new MyLinkedList<>(); for (int i = 0; i < 10; i++) { mll.add(i);}for (int i = 0; i < 10; i++) {System.out.println(mll.get(i)); }}} |
You have also been provided with a tester file called Tester.java which contains more simple tests of every method.
Rubric
- [20] add(int index, E element)
- [3] Correctly throws exceptions
- [17] Functionality
- [12] add(E element)
- [2] Correctly throws exceptions
- [10] Functionality
- [12] get(int index)
- [2] Correctly throws exceptions
- [10] Functionality
- [12] remove(int index)
- [2] Correctly throws exceptions
- [10] Functionality
- [12] removeElement(E element)
- [2] Correctly throws exceptions
- [10] Functionality
- [12] contains(E element)
- [2] Correctly throws exceptions
- [10] Functionality
- [5] isEmpty()
- [5] clear()
- [5] size()
- [5] toArray()
Import Restrictions
You may not import anything for this homework assignment.
Feature Restrictions
There are a few features and methods in Java that overly simplify the concepts we are trying to teach or break our auto grader. For that reason, do not use any of the following in your final submission:
- var (the reserved keyword)
- exit
Reviews
There are no reviews yet.