Note: You can work either
individually or with a partner for Lab 6. You can select your partner or TA can
assign you one.
Our main objective today is to learn
You will both design your own interface for a class RandomString and also implement this class. This class will store an array of 10 Strings, these strings can be any based on your definition. One of which will be randomly returned everytime user needs a String. Also, provide a curious user with a method that prints out all the strings from the array, so that the user knows what Strings you generated (we are mainly using this method to understand the usage of for loop).
To know more about Random class, use this link: http://java.sun.com/j2se/1.5.0/docs/api/
Note: Your code should have a simple test to see that the program never tries to access a String outside the array bound.
Once you finish implementing your class please document it. Your documentation should be of javadoc style. Make sure you create html files.
Thus, one design for this class is as shown below. You can be more creative and use your own design.
public Class RandomString
{
// some example of fields are
// constructor for RandomString
{
// you and your partner will decide what you put here
}
// methods, one method will be
public String generateRandomString()
{
// Use random object to access String from your array of 10 strings.
Hint: Your random numbers should be from 0 through 9, so use the method from Random object wisely.
}
public void printStrings()
{
// Use for loop to printout the names of the String.
}
}