A video demonstrating a solution can be found here.In the extensions source folder, find and open the lines package and the Lines class contained therein. The main method is provided, and it calls the method drawLine,which you must complete.
Do not change the parameters or return type of the drawLine method! You are welcome to define other methods in the Lines class if you wish, but the drawLine method's signature (the number and types of its parameters and its return type) must be preserved as you do your work.
Your task is to devise an algorithm for drawing a line from (x1,y1) to (x2,y2) using recursion. It may take you some time to think about how to do that, but once you see the recursive nature of drawing a line, you will probably need only a few lines of code to accomplish this task.
Please take note of the following guidelines, as you will not receive credit unless your solution follows the rules of this assignment:
This means you must draw your line one point at a time.
Do not compute or use the slope of the line in your approach. We will not count the extension if you do that. Instead, think recursively about how a line is constructed.
When you done with this extension, you must be cleared by the TA to receive credit.
- Commit all your work to your repository
- Fill in the form below with the relevant information
- Have a TA check your work
- The TA should check your work and then fill in his or her name
- Click OK while the TA watches
- If you request propagation, it does not happen immediately, but should be posted in the next day or so
This demo box is for extension 6.1
In the extensions folder open the recursivepatterns package and the PersianRug class. Your task is to complete the method persianRug so that it draws a rug similar to the one shown below:
- A video demonstrating my solution can be found here.
- That video instructs you how to speed up the drawing substantially.
- Don't speed things up until you see the rug is drawing properly.

Computing the color of these two lines is what makes the rug look as it does. More detail is given below concerning how to pick a color.
The parameters for persianRug are documented in the source code provided to you for this extension.
Notes:
As you know, 0 is the smallest index, and the largest index is palette.length-1.
Recall that these colors are represented as integers, each being an index into the palette array. What kinds of functions on integers return the same result no matter the order of those integers?

![]() |
![]() |
![]() |
| Ben Greene | Dylan Jew and Ari Spilo | Alan Waldman |
![]() |
![]() |
![]() |
| Sam Chase | Meagan Provencher | Ben Zod |
![]() |
![]() |
![]() |
| Diana Fasanello | Anna Kolasa and Kunyao Liu | Jeremy Scharf |
When you done with this extension, you must be cleared by the TA to receive credit.
- Commit all your work to your repository
- Fill in the form below with the relevant information
- Have a TA check your work
- The TA should check your work and then fill in his or her name
- Click OK while the TA watches
- If you request propagation, it does not happen immediately, but should be posted in the next day or so
This demo box is for extension 6.2
A video demonstrating my solution can be found here.In the extensions folder open the recursivepatterns package. The following classes found there, and described in greater detail below, must be completed for this extension:

You can proceed by working on either class first. However, if you postpone TransparentColor, you will see solid colors in your flower until you have completed that class.
The transparentColor method, as provided to you, ignores the alpha parameter and returns the color provided as input.
You must change this behavior so that the color returned as the same red, green, and blue components as the provided color, but with the specified transparency.Java makes this easy, because there is a constructor for Color that does the job. This task is given to you primarily to acquaint you with the process of looking through JavaDoc documentation to find a class or method you need.
Follow the instructions provided in the TransparentColor source code.
Before moving on, test your code by running TransparentColor as a Java Application. You should see the colors solid at the upper right of the drawing window, and blended (more transparent) at the lower left.You must demo this to a TA when you seek credit for this extension.
If necessary, review the material in the text and slides that discusses how to pick a random integer. You would use that integer to index the palette array.

When you done with this extension, you must be cleared by the TA to receive credit.
- Commit all your work to your repository
- Fill in the form below with the relevant information
- Have a TA check your work
- The TA should check your work and then fill in his or her name
- Click OK while the TA watches
- If you request propagation, it does not happen immediately, but should be posted in the next day or so
This demo box is for extension 6.3
As a hint, you will need two variables that represent the (n-1)th and (n-2)th values of the sequence. Adding those together produces the nth term. The variables' values are then shifted prior to the next iteration.
When you done with this extension, you must be cleared by the TA to receive credit.
- Commit all your work to your repository
- Fill in the form below with the relevant information
- Have a TA check your work
- The TA should check your work and then fill in his or her name
- Click OK while the TA watches
- If you request propagation, it does not happen immediately, but should be posted in the next day or so
This demo box is for extension 6.4
Issues: Not yet ready
Warning: You must have a complete and working tictactoe extension before you take on this work. So make sure you already have credit for that extension and that all method work properly.
Your task in this extension is to design a robot player that plays tic-tac-toe perfectly. Once this player is implemented correctly, it should never lose, regardless of whether it makes the first move or not. Note that a tic-tac-toe game between two perfect players will always end in a tie.
Inside the extensions folder is a tictactoexpert package, which contains the following:
There is a simple, complete robot player implemented in the DumbPlayer class that you can look at for reference.
You can find outline of tic-tac-toe strategy here, which can be turned into a simple algorithm for the robot player. This algorithm doesn't strictly need recursion, but you will find that creating and blocking forks is much more easily accomplished by calling the makeMove method recursively. This will allow you to predict the state of the board several moves ahead and decide if a move actually produces a fork.
In a tic-tac-toe game, the first and second moves are extremely important. You may want to handle these moves individually before moving on to a more general algorithm.
You can test your perfect robot player with the TestPerfectPlayer JUnit test. Be aware that this test is not exhaustive (even after passing, the robot player could be making some mistakes) but it is sufficient to get credit for this extension.
When you done with this extension, you must be cleared by the TA to receive credit.
- Commit all your work to your repository
- Fill in the form below with the relevant information
- Have a TA check your work
- The TA should check your work and then fill in his or her name
- Click OK while the TA watches
- If you request propagation, it does not happen immediately, but should be posted in the next day or so
This demo box is for extension 6.5