/** * This class can be used to generate random letter sequences * * @author (your name) * @version (a version number or a date) */ public class SequenceGenerator { // instance variables - replace the example below with your own private String seqAlphabet; /** * Constructor for objects of class SequenceGenerator */ public SequenceGenerator() { seqAlphabet = "abcdefghijklmnopqrstuvwxyz"; } /** * Constructor for objects of class SequenceGenerator, using a restricted alphabet * * @param alphabet a string of letters that can be used in the random sequences */ public SequenceGenerator(String alphabet) { seqAlphabet = alphabet; } /** * Generates a random letter sequence of the spceified length * * @param seqLength the number of letters in the random sequence * @return the random letter sequence */ public String randomSequence(int seqLength) { String seq = ""; for (int i = 0; i < seqLength; i++) { int index = (int)(Math.random()*seqAlphabet.length()); seq = seq + seqAlphabet.charAt(index); } return seq; } }