8A

Create a class Liners representing a series of horizontal lines. The constructor takes three parameters: The x and y coordinates of the left-hand side of the first line and the number of lines. The length of the first line is 20 times the number of lines. Each successive line is 15 pixels shorter than the one before. The lines are spaced 5 pixels apart. Define and use constants.

Provide a draw method that draws the pattern of lines. You must use a loop.

Provide Javadoc

For the draft: Provide the constructor and the instance variables. In the draw method, draw the first line of the correct length

Your final will look like this

linew screenshot

8A draft:
8A final:

8B

Write a class StringsAgain whose constructor takes a String parameter. StringsAgain has the following methods:

Provide Javadoc for the class, the constructor and all methods

For the draft: Provide instance variables. Implement the constructor. Implement the first two methods completely. Implement the last two methods as stubs. Provide all the Javadoc. For the stubs, document what the method will do in the final - not what it does in the draft

8B draft:
8B final:

8C

In this problem you write a PatchworkQuilt class which will model a simple patchwork quilt. The quilt consists of 8 rows of squares. Each row contains 7 squares. Each square is a random Pattern constructed from the Pattern class which is provided. Here are a couple of image of a patch work quilts, in case you are not familiar with them.

quilt sample quilt

You can look at the Javadoc for the Pattern class by selecting it in the Bluej Editor and then selecting Documentation in the drop-down menu on the right. I have also included a PatternTester class so you have an example of how to use the class. You can download both from Codecheck. Notice that Codecheck reports an error with PatternTester. Just ignore it. If your code is correct, you will still pass Codecheck with 1/1. It will run correctly in Bluej.

Write the PatchworkQuilt class. You must use nested loops. Draw the rows and then the columns to keep Codecheck happy. Use the constants provided.

The PatchworkQuilt will have this constructor and these methods

The Pattern class has 4 different pattern types. To determine which pattern to return in getPattern method you will generate a random number between 0 (inclusive) and 4 (exclusive) and then construct a Pattern with that parameter Pattern myPattern = new Pattern(gen.nextInt(4));

In PatchworkQuilt's draw method, you will create a Pattern and use its translate method to move it to the correct position. Use the constant Pattern.SIDE (the width and height of the square) to position the square.

You will need to import the graphics package into Bluej.

Because the Random object is created with a seed, you will all get the same drawing every time. That is so Codecheck can check it.

For the draft, complete the constructor to initialize the instance variables. Write a draw method that draws the first row starting at the given (x, y) coordinates. (This will become the inner loop of the final. Call getPattern() to get the squares to use. Right now getPattern always returns BLUE_CIRCLE square. (You will change that in the final) You must use a loop. You will not receive credit for simply drawing 8 squares.

Your final output will look like this

quilt screen shot

8C draft:
8C final: