Will You Repeat That?Loops in Java

Due Date: Monday April 17, 2000 at 8:00 am

*Jim's Sample Solution! *

Assignment:
Time to work with two things introduced in the Robot Programs We need to visit iteration (for, while, do) and the use of a class someone else (Jim) wrote. You are going to use Jim's Monogram class and loops to draw patterns of monograms on the screen. There are five patterns chosen by button clicks in the applet. You will use the default Layout manager, FlowLayout for this lab. When the user clicks on a button, your applet will draw that pattern of monograms in the applet window The monograms must be very close to the upper and left edges of the applet window. They should be as close as possible to the right and bottom edge without causing partial monograms to be drawn. Your applet must respond to changes in the applet window. It cannot be hardwired into a constant width or height. To do this you will need to use a Dimension object that is discussed in Chapter 2 on pages 48-50 and in the Class Reference on pages 66 and 67.

The possible patterns are:
- horizontal line (vertical location is of your choosing)
- vertical line at the left (horizontal location is of your choosing)
- diagonal line from upper left corner extending down to the right until it runs out of room in the applet window. Note that if the applet window is not a square, this diagonal line will not go to the lower right corner of the box
- a frame of monograms made of two; horizontal lines of monograms - one at the top and one at the bottom o the applet window and two vertical lines of monograms - one at the left edge and one at the right edge of the applet window.
- a solid carpet of monograms that covers the entire applet window.

Background
There are a lot of details that you can learn by looking at a working example. To save you some time and frustration, the horizontal line has been coded for you. You can get a folder named Lab12Distribution that has a .java, .html, and .class file the from the handouts folder in the course volume at: /afs/andrew.cmu.edu/course/15/120/handoutsYou should use this to start coding the lab

Handin Instructions:
Create a folder named according to the tradition of the first seven labs. Put the .html and .java file into that folder. DO NOT HAND IN THE .class FILE!


FTP your folder to the usual place. Look for a folder marked Lab12.


15-120 Spring 2000                                                                   Lab 12

Back to 15-120 Assignments