Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am working on a assignment of Java programming, I have provided some codes already and I need to add some methods to make it
I am working on a assignment of Java programming, I have provided some codes already and I need to add some methods to make it work.
The weapons.txt is like this
I have added my method into the Class Weapon, but I got a error on line 21, and I don't know how to fix it.
Task 1 The first task is to read in the weapons and characters. I have provided you with two files, weapons.txt and suspects.txt based on the original board game but you are welcome to substitute your own data. The weapons file must contain the names of six weapons, one to a line, but if you would prefer a non lethal version feel free to substitute alternatives (feather duster, pillow...) but there must be six, the file must be called weapons.txt and must be in the same directory as all the class files. For the suspects file you can also substitute different names (your flat mates perhaps or those of your more irritating relatives). These must also be one to a line but, unlike in the game, there can be any number between three and ten. This file must called suspects.txt and must also be in the same directory as all the class files. To read these data files in you must modify both the Weapon. java class and the Suspect.java class. I suggest you tackle them in that order because the weapons are easier and you can still get marks for getting that right even if Suspect. java doesn't work. The Weapon. java class contains this method public static void initializeThem() \{ //Fill in this method body with your code for Task 1 3 and you should replace its body with your own code to read in the names of the weapons from weapons.txt using EasyReader and turn each of them into a Weapon object stored in the array called allTheWeapons. Having done so you must print them out by calling the method listTheWeapons() which has already been created for you. In doing this you can only change the body of the method initializeThem (), nothing else. Reading in suspects.txt is similar except that the file may not contain six suspects. The method whose body you have to change is called initializeEveryone and the array you need to populate with Suspect objects is called allTheSuspects. For this task you also need to make sure that your method sets the value of the variable number0fSuspects. Your method body must end with a call to the method listTheSuspects() which already exists. You can test your code by running the program. The output should now inclued the first two lines of the sample output above - the ones listing the weapons and suspects although possibly with different suspects and weapons. If you do this with two perfectly written methods that demonstrate the techniques identified in the marking scheme you can expect to get 22%. Candlestick Dagger Lead Pipe Revolver Rope WrenchStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started