Sett, SettDrawer, SettComponent, and SettElement, with methods and classes as specified below.
The SettComponent class may be taken from the test file A6.java for Assignment 6, except that it needs to be made public (and not an inner class). The SettElement class merely packages a Color and an integer representing a width; this class may be taken from my Sett class for Assignment 6. Again, this class is to be a public class in a file by itself. In general, you may use any part of my solution to Assignment 6 with appropriate credit.
The Sett class is to have public methods draw and setLocation, as in Assignment 6. The draw method may incorporate the extra credit component of Assignment 6, although it needn't. One difference from Assignment 6 is that this assignment's constructor is to take an ArrayList of SettElement objects, rather than two arrays. The idea here is to avoid the use of parallel arrays, for reasons stated on pp. 276-7 of the text.
The SettDrawer class is to contain most of the new functionality. The default constructor is acceptable for this class. The only required method is a public nonstatic method drawSetts that takes two strings as arguments. The second argument is to be the name of a "log file" to which acknowledgements and error messages are to be written. The first argument is to be the name of a file that contains a sequence of sett specifications, with no blank lines in between. The method is to construct and draw a Sett for each specification in the file, until the file is exhausted or an error is encountered. In particular, your method will have to arrange to translate sett specifications into legal arguments for the Sett constructor.
A legal sett specification consists of a line of text representing a clan name, followed by
zero or more lines representing sett elements, followed by a line containing only an asterisk. Clan names may be empty strings. A legal line representing a sett element consists of a lower-case letter followed by a nonnegative integer, with no space in between. The lower-case letter is to be interpreted as the color component of a
The interpretation as colors of lower-case letters is to be as follows: the characters
'k', 'p', 'r', 'w', and 'y' are to be interpreted as the respective colors BLACK, PINK, RED, WHITE, and YELLOW. The characters 'b' and 'g' are to have the same interpretations as the constants DARK_BLUE and DARK_GREEN of
When a sett is drawn onto a frame, the frame is to have the corresponding clan name as its title. This is the only explicit use of clan names in this assignment.
When the
You are strongly encouraged to use one or more private methods to assist the
If the file that is specified as the log file for the
Be warned that the Ogilvie sett takes a while to draw. You may decide that it's worth the wait.
For this assignment, you are to turn in hard and soft copies of your class definitions. You are also to turn hard copies of the two log files created by testing with the class
SettElement; the integer is to be interpreted as the width component. So for example, the Brodie tartan would have a representation consisting of the 8 lines Brodie,
k4, r32, k16, y2, k16, r4, and *.A6.java. The character 'a' is to be interpreted as a new (light blue) color with respective R, G, and B components 128, 128, and 255. All other lower-case characters are to be interpreted as the color GRAY. It is an error for any character other than a lower-case letter to begin the representation of a sett element.drawSetts method encounters an error, including a "file not found" error, it is to print an appropriate and informative error message both to the console and to the log file, and then terminate. When the clan name portion of a sett specification is read, an acknowledgement of the beginning of the drawing of that clan's sett is to be printed to both the console and the log file. This is the only printing that any of your methods needs to do, except that when the drawSetts method finishes, it should print a new (blank) line to the console and the log file. Do make sure that if the drawSetts method terminates early due to an error, this line is printed and all of your Scanner and PrintWriter objects are closed (you should be using these two classes for your input and output).drawSetts method in its work. Presumably some of these methods will pass exceptions to drawSetts, or propagate to drawSetts exceptions passed from other methods.drawSetts method already exists, you should append to it rather than overwrite it. This may be done by using a 2-argument constructor for the FileOutputStream class with second argument true. However you should make sure that the log files that you turn in contain the results of only one execution of your program.A7.java, available from the class web site. Note that this class assumes the existence of 10 input files. These files are also available on the class web site. Finally, please make sure that you are familiar with the instructions in the handout on assignments for submitting soft copies of an assignment with multiple files.