Hi there.
As some may remember I used to come here for a lot of help with Java. Sadly, I've come back for more help - I hope some people more clued up on the subject than me can help me out. I'd always try and help others out but I'm just not that good at it.
Anyway, I'm now in my second year of university, and my new Java teacher swears by making Tester classes for any Java class files we make.
So, what I need to know is is there any certain requirements a Tester class needs? I know that it would need a
main method, as it would be the Java class that is run.
I really don't know how to link the Tester class and the initial class together in order to run properly.
This is a class I found in a textbook earlier and got to run, however, it's just one initial class.
This class generates a random number from 0 and the size of each word list array and then picks a word at random from each list to generate a sentence which is printed to screen:
Code:
public class PhraseOMatic
{
public static void main (String[] args)
{
//Makes the three lists of words
String[] wordListOne = {"24/7", "multi-Tier", "30,000 foot", "B-to-B", "win-win", "front-end",
"web-based", "pervasive", "smart", "six-sigma", "critical-path", "dynamic"};
String[] wordListTwo = {"empowered", "sticky", "value-added", "oriented", "centric", "distributed",
"clustered", "branded", "outside-the-box", "positioned", "networked", "focused",
"leveraged", "aligned", "targeted", "shared", "cooperative", "accelerated"};
String[] wordListThree = {"process", "tipping-point", "solution", "architecture", "core competency",
"strategy", "mindshare", "portal", "space", "vision", "paradigm", "mission"};
//Finds out how many words are in each list of words
int oneLength = wordListOne.length;
int twoLength = wordListTwo.length;
int threeLength = wordListThree.length;
//Calculations to generate the three random numbers
int rand1 = (int) (Math.random() * oneLength);
int rand2 = (int) (Math.random() * twoLength);
int rand3 = (int) (Math.random() * threeLength);
//Here, the phrase is built
String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];
//Prints out the phrase to screen
System.out.println("What we need is a " + phrase + ".");
}
}
Now if I were to create a Tester class for this class, how the heck would I go about doing it?
I hope people understand where I'm coming from here.
Thanks very much.