class helloOBJ
{
Integer count;
String Greeting;
helloOBJ() {
count = 10;
Greeting = "Hello World.";
}
void assignGreeting(String s) {
if(s!="") Greeting = s;
}
void assignCount(Integer i) {
if(i>0) count = i;
}
public void run() {
for(Integer i=1; i<=count; i++)
{
System.out.printf("[%04d] %s\n", i, Greeting);
}
}
}
class helloAPP
{
public static void main(String[] args)
{
Integer pramCount = args.length;
helloOBJ myObj = new helloOBJ();
try {
if(pramCount>=1) {
Integer j = Integer.parseInt( args[0] );
myObj.assignCount( j );
}
if(pramCount>=2)
myObj.assignGreeting( args[1] );
myObj.run();
} catch (Exception e) {
System.out.println("An error occured, check arguments.");
}
}
}
Syntax
helloAPP [count [custom string]]
