Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4.17 Ch 4 Program, Part 2: Clue Eye Witness Method The goal of this problem is to build on the previous exercise and make a

image text in transcribedimage text in transcribed

4.17 Ch 4 Program, Part 2: Clue Eye Witness Method The goal of this problem is to build on the previous exercise and make a user-defined method that can take input and output the correct message. You will also build a test method to ensure that your new method works as expected. You will add a new method that takes in the murderer as an input and returns the murder message. Note: this new method should return a String rather than printing a String. You will also create a test method to make sure that your new method works as expected. You will call the test method from the main method. (1) Complete the following method: /** * Determines the detective's message. The input should be case insensitive. * If the murderer is not recognized or is null, the message * "We're not sure who that is. We need to investigate further." is returned. * @param murderer abbreviation. * @return The detective's message for a given murderer. public static String murdererMessage (String murderer) { // FILL IN BODY Like in part 1 this method emulates a detective questioning an eye-witness of a murder. The detective has three suspects each with a potential murder weapon. Based on the eye-witness's user input, the detective will reach a conclusion about the murderer and the murder weapon. If the witness input is "Amos" the detective will output "It was Amos with the candlestick!" If the witness input is "Kevin", the detective will output "It was Kevin with the revolver!" If the witness input is "Juan", the detective will will output "It was Juan with the lead pipe!" Otherwise, the detective will output "We're not sure who that is. We need to investigate further." Example method input: kevin Example method return value: It was Kevin with the revolver! Now create a test method to verify that your method in part(1) works as expected. Each test case should print out the value of the method directly without saving it in a local variable (print the value returned by the method). Try testing various types of capitalization (2) Complete the following method: /** * Runs tests to validate the detective's message via the murderMessage method **/ public static void testMurdererMessage() { System.out.println("murdererMessage ( \"AMOS ") expected \"It was Amos with the candlestick!" actual "" + murdererMessage ("AMOS") + " ""); System.out.println(/* FIX ME */); System.out.println( /* FIX ME */); (3) Call your test method from your main method Before turning in, remember to Style and Comment following the course standards CS 200 Style. Created by Amos - Reviewed by Kevin LAB ACTIVITY 4.17.1: Ch 4 Program, Part 2: Clue Eye Witness Method 0190 Clue.java Load default template... Load defau 19 // 20 /IIIIIIIIIIIIIIIIIIIIIIIIIIIIII 80 COLUMNS WIDE IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 21 import java.util.Scanner; 22 public class Clue{ 23 public static void main(String[] args) { /* call your test method here*/ 26 } /* Add your methods here */

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

4. Who would lead the group?

Answered: 1 week ago

Question

Where those not participating, encouraged to participate?

Answered: 1 week ago