Question: Compile and run (make sure programs runs as specified). /* File: HelloWorldThree.java * Author: Big Boss * CST 261 - ### * Instructor: Professor Kojima
Compile and run (make sure programs runs as specified).
/* File: HelloWorldThree.java
* Author: Big Boss
* CST 261 - ###
* Instructor: Professor Kojima
* Date: January 1, 1970
*
* Description: Yet another unnecessarily complex version of "hello, world!".
*
*/
/*
* HelloWorldThreeAlt class
*
* Contains the entry point for the program and all programming logic and
* the helper class, HelloClass
*/
public class HelloWorldThree {
/*
* main method
*
* Preconditions: String s as a program argument
* Postconditions: String is displayed on stdout
*
*/
public static void main(String[] args)
{
String result;
HelloWorldThree project = new HelloWorldThree();
HelloClass myHelper = project.new HelloClass();
if (args.length == 1 &&
(args[0].equals("-h") || args[0].equals("-w")))
{
myHelper.setResult(args[0]);
result = myHelper.getResult();
System.out.println(result);
}
else if (args.length == 0)
{
myHelper.setResult("default");
result = myHelper.getResult();
System.out.println(result);
}
else
{
result = "Provide correct commmand line arguments or no argument!";
System.out.println(result);
}
}
/*
* HelloClass class
*
* Helper class that generates the results of the program. The public
* interface consists of the setResults and getResults methods.
*
*/
private class HelloClass {
private String result;
private String hello;
private String world;
HelloClass()
{
//TODO: Your code goes here
}
/*
* setResult method
*
* Preconditions: String s passed as an argument
* Postconditions: "result" is assigned the value in "s"
*
*/
public void setResult(String s)
{
// TODO: Your code goes here.
} // end setResult method
/*
* getResult method
*
* Preconditions: none
* Postconditions: Returns result
*/
public String getResult()
{
// TODO: Your code goes here
} // end getResult method
} // end of class HelloClass
} // end of class HelloWorldThree
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
