I have been given a project called "Assassin" friom my computer science class, and I cannot seem to be able to create the correct methods in order to run this code properly. I am going to paste my current code for this project. If you would like the instructions, please allow me to either email or create another query, as the instructions are on a word document. Please offer assitance if you can, thank you. My current code: import java.io.*; import java.util.*; /**  * Class AssassinMain is the main client program for assassin game management.  * It reads names from a file names.txt, shuffles them, and uses them to start  * the game. The user is asked for the name of the next victim until the game is  * over.  */ public class AssassinMain {     /**      * input file name from which to read data      */     public static final String INPUT_FILENAME = "names.txt";     /**      * true for different results every run; false for predictable results      */     public static final boolean RANDOM = false;     /**      * If not random, use this value to guide the sequence of numbers that will      * be generated by the Random object.      */     public static final int SEED = 42;     public static void main(String[] args) throws FileNotFoundException {         // read names into a Set to eliminate duplicates         File inputFile = new File(INPUT_FILENAME);         if (!inputFile.canRead()) {             System.out.println("Required input file not found; exiting.\n" + inputFile.getAbsolutePath());             System.exit(1);         }         try (Scanner input = new Scanner(inputFile)) {             Set names = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);             while (input.hasNextLine()) {                 String name = input.nextLine().trim().intern();                 if (name.length() > 0) {                     names.add(name);                 }             }             // transfer to an ArrayList, shuffle and build an AssassinManager             ArrayList nameList = new ArrayList<>(names);             Random rand = (RANDOM) ? new Random() : new Random(SEED);             Collections.shuffle(nameList, rand);       AssassinManager manager = new AssassinManager(nameList);  // UNCOMMENT ONCE YOU WRITE THE CONSTRUCTOR             // prompt the user for victims until the game is over             Scanner console = new Scanner(System.in);       while (!manager.isGameOver()) {                           oneKill(console, manager);             }             // report who won             System.out.println("Game was won by " + manager.winner());  // UNCOMMENT ONCE YOU WRITE winner()             System.out.println("Final graveyard is as follows:");             System.out.println(manager.graveyard());      // UNCOMMENT ONCE YOU WRITE graveyard()         }     }     /**      * Handles the details of recording one victim. Shows the current kill ring      * and graveyard to the user, prompts for a name and records the kill if the      * name is legal.      */     public static void oneKill(Scanner console, AssassinManager manager) {         // print both linked lists         System.out.println("Current kill ring:");       System.out.println(manager.killRing());      // UNCOMMENT ONCE YOU WRITE killRing()         System.out.println("Current graveyard:");       System.out.println(manager.graveyard());     // UNCOMMENT ONCE YOU WRITE graveyard()         // prompt for next victim to kill         System.out.println();         System.out.print("next victim? ");         String name = console.nextLine().trim();       if (manager.graveyardContains(name)) {                // UNCOMMENT ONCE YOU WRITE graveyardContains(name)             System.out.println(name + " is already dead.");         } else if (!manager.killRingContains(name)) {           // UNCOMMENT ONCE YOU WRITE killRingContains(name)             System.out.println("Unknown person.");         } else {             manager.kill(name);                                 // UNCOMMENT ONCE YOU WRITE kill(name)         }        System.out.println();     } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I have been given a project called "Assassin" friom my computer science class, and I cannot seem to be able to create the correct methods in order to run this code properly. I am going to paste my current code for this project. If you would like the instructions, please allow me to either email or create another query, as the instructions are on a word document. Please offer assitance if you can, thank you.

My current code:

import java.io.*;
import java.util.*;

/**
 * Class AssassinMain is the main client program for assassin game management.
 * It reads names from a file names.txt, shuffles them, and uses them to start
 * the game. The user is asked for the name of the next victim until the game is
 * over.
 */
public class AssassinMain {

    /**
     * input file name from which to read data
     */
    public static final String INPUT_FILENAME = "names.txt";

    /**
     * true for different results every run; false for predictable results
     */
    public static final boolean RANDOM = false;

    /**
     * If not random, use this value to guide the sequence of numbers that will
     * be generated by the Random object.
     */
    public static final int SEED = 42;

    public static void main(String[] args) throws FileNotFoundException {
        // read names into a Set to eliminate duplicates
        File inputFile = new File(INPUT_FILENAME);
        if (!inputFile.canRead()) {
            System.out.println("Required input file not found; exiting.\n" + inputFile.getAbsolutePath());
            System.exit(1);
        }
        try (Scanner input = new Scanner(inputFile)) {
            Set<String> names = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
            while (input.hasNextLine()) {
                String name = input.nextLine().trim().intern();
                if (name.length() > 0) {
                    names.add(name);
                }
            }

            // transfer to an ArrayList, shuffle and build an AssassinManager
            ArrayList<String> nameList = new ArrayList<>(names);
            Random rand = (RANDOM) ? new Random() : new Random(SEED);
            Collections.shuffle(nameList, rand);

      AssassinManager manager = new AssassinManager(nameList);  // UNCOMMENT ONCE YOU WRITE THE CONSTRUCTOR

            // prompt the user for victims until the game is over
            Scanner console = new Scanner(System.in);
      while (!manager.isGameOver()) {          
                oneKill(console, manager);
            }

            // report who won
            System.out.println("Game was won by " + manager.winner());  // UNCOMMENT ONCE YOU WRITE winner()
            System.out.println("Final graveyard is as follows:");
            System.out.println(manager.graveyard());      // UNCOMMENT ONCE YOU WRITE graveyard()
        }
    }

    /**
     * Handles the details of recording one victim. Shows the current kill ring
     * and graveyard to the user, prompts for a name and records the kill if the
     * name is legal.
     */
    public static void oneKill(Scanner console, AssassinManager manager) {
        // print both linked lists
        System.out.println("Current kill ring:");
      System.out.println(manager.killRing());      // UNCOMMENT ONCE YOU WRITE killRing()
        System.out.println("Current graveyard:");
      System.out.println(manager.graveyard());     // UNCOMMENT ONCE YOU WRITE graveyard()

        // prompt for next victim to kill
        System.out.println();
        System.out.print("next victim? ");
        String name = console.nextLine().trim();

      if (manager.graveyardContains(name)) {                // UNCOMMENT ONCE YOU WRITE graveyardContains(name)
            System.out.println(name + " is already dead.");
        } else if (!manager.killRingContains(name)) {           // UNCOMMENT ONCE YOU WRITE killRingContains(name)
            System.out.println("Unknown person.");
        } else {
            manager.kill(name);                                 // UNCOMMENT ONCE YOU WRITE kill(name)
        }
       System.out.println();
    }
}

 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 6 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question
Your Question:

While your code does work, there is the problem of the constraints put on us for this project. I will paste them from the instructions document.

Constraints 

• You may not construct any arrays, ArrayLists, LinkedLists, Stacks, Queues, or other data 

structures; you must use list nodes. You may not modify the list of Strings passed to your constructor. 

 

• If there are n names in the list of Strings passed to your constructor, you should create exactly n new AssassinNode objects in your constructor. As people are killed, you have to move their node from the kill ring to the graveyard by changing references, without creating any new node objects. 

 

• Your constructor will create the initial kill ring of nodes, and then your class may not create any more nodes for the rest of the program. You are allowed to declare as many local variables of type AssassinNode (like current from lecture) as you like. AssassinNode variables are not node objects and therefore don’t count against the limit of n nodes. You should write some of your own testing code. AssassinMain requires every method to be written in order to compile, and it never generates any of the exceptions you have to handle, so it is not exhaustive. 

Would it be possible to adjust the code within these parameters? These limitations are the main issue when trying to create a solution.

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education