Java Task: Please help me to write a series of command line arguments that, when correctly specified, will cause the program to run to completion
Java Task:
Please help me to write a series of command line arguments that, when correctly specified, will cause the program to run to completion. This program is about a Puzzle.
The command line arguments must make the program to run to completion. Please read and help me. Thank you
Here is the task and example:
A Programming Puzzle
The file debugme/DebugMe.java is provided in the code pack and contains a puzzle. The main() method in this program accepts a series of command line arguments that, when correctly specified, will cause the program to run to completion. If the command line arguments are not specified correctly, the program will fail prematurely. The purpose of this problem is to determine the correct inputs to cause the program to run to completion.
DebugMe is arranged in "stages" and passing stages earns points. After each run the program prints the points earned based on the stages "passed". Example:
> java DebugMe userID(abc#) 0 0 0 Let the games... BEGIN! Phase One, let's have some fun! Double debugger burger, order up! oops! Game Over... >:( * Score: 0/55 pts *
Notice that the first argument is always your UserID(abc#). DebugMe uses your UserID(abc#) to create a unique set of conditions which you must pass so that your experience with the program will likely be different from other students.
This task is actually kinder to you - if you fail one phase, you are able to continue to the next.
The stages in DebugMe are intentionally obscure. This is code that is meant to be a puzzle rather than easily readable and to that end, you are strongly encouraged to use a debugger while analyzing the program. Debuggers allow you to stop execution at any point and examine variables, step forward line by line, and ultimately identify which kinds of command line arguments will make it through a stage and which will cause the dreaded failure() method to be invoked ending the run. A primary goal of this problem is to gain experience with debuggers as they are incredibly useful tool for a programmer to have in their utility belt. Credit for the problem is entirely based on how many stages are passed.
Command Line Arguments
The only artifact of your efforts will be the specific command-line invocation of the program, as your only inputs are given as command-line arguments.
the first command-line argument must be your UserID. Many of the phases will use this to randomize and personalize the code for you - you've got your very own unique project!
each phase (method) will read the next few arguments (however many it needs), and use them in more and more quirky ways.
towards the end of each phase, there will be some check and a guarded call to failure(). Your goal is to figure out what command-line arguments will cause these failures to never happen.
if you need to include spaces in a single argument, please use double-quotes.
Running DebugMe through the Debugger
How can we use the debugger with command-line arguments? It's surprisingly easy in DrJava:
Compile DebugMe.java
Set a breakpoint in the phase you're working on
Turn on debugging mode under the debugging menu
In the Interactions Pane, run a command like this to launch DebugMe with command line arguments.
> java DebugMe UserID 0 0 0 Let the games... BEGIN! Phase One, let's have some fun! oops! Game Over... >:( error msg: Failure! Double debugger burger, order up! * Score: 0/55 pts.
If you've turned on debugging, though, you get to step through and see what's happening.
Most IDEs have a means of running a program through a debugger. Learn about your tool if you are not using DrJava.
For the brave, there is also a command line debugger, command jdb which should be installed with every JDK. This is somewhat less convenient as it provides only limited source code display but can work with some classic unix tools.
Regardless of how you access the debugger, you will want to familiarize yourself with features such setting breakpoints to stop the running program, stepping forward line by line, and displaying the values of variables.
DebugMe is not a "real" program as it is intentionally obscure. However, as an exercise to learn how to analyze running programs it will provide invaluable experience. Happy bug squashing.
------Here is the java codes----
import java.util.*;
public class DebugMe { public static void main(String[] args){ int argsNeeded = 29; if (args.length
Here is an additional link to the codes: https://paste.ee/p/RIDxP
Please help if you can. Thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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