Chapter 3 (pages 119 - 177) in Java Programming: From Problem Analysis to
Program Design, 3rd Edition, by D. S. Malik, Thomson Course Technology,
This assignment has two parts. All parts must be completed for full
Part 1: Have It
- Re-open your Picture project from the first
assignment. You want to work in the same project so that you have
the Square, Circle, Triangle, and Canvas classes at your disposal.
- Modify PictureDriver so that it starts with a dialog
with the user. The dialog should:
- (5 points) Ask
the user for his/her first name
- (5 points)
Welcome the user by first name
- (5 points) Offer
a summary description of the picture, clearly identifying one main
component and one secondary component of the picture. (For example:
"Hello, Amber. I will create for you a picture of a house with
a square living space and a triangular roof.")
- After the welcome dialogue, you will ask the user for
information on how to draw the two identified components. In
particular, you will ask:
- (20 points) What
color does the user want each component to be? This will be two
questions, one per shape.
- (15 points) What
size does the user want the main component to be? Be
specific here. If the main component is a triangle, you will need
two pieces of information. If it is a square or a circle you will
need only one. Think about what type makes the most sense for this
- (25 points) Your next task is to redraw the
picture incorporating the information from the user. This means that
the size of all other components of the picture will need to be
recalculated based on the size information obtained from the user.
For example, if the user changes the size of the main wall of the house, I
would have to change the size of the roof accordingly. Note that
components may get shifted around, so that if the size change is large
enough, the drawing may no longer look correct. Fixing this is extra
credit and is detailed in the next step.
- (Extra credit: 5 points) Complete the above task
so that the appearance of the drawing do not change. This means that
not only the size but also the positioning of all other components of the
picture will need to be recalculated based on the size information
obtained from the user. For example, if the user changes the size of
the main wall of the house, I would have to change the size and position
of the roof accordingly. The final picture should be an exact, but
larger or smaller, copy of the original one.
- (10 points) After showing the picture to the
user, you will pretend to have an audience of two people and will ask for
two "grades" on your work. The grades will be numerical
values from 1 to 5, with 1 being "ugliest thing I've ever seen"
and 5 being "a masterpiece". Indicate what the scale means
so that the user does not accidentally give your work an inaccurate grade.
- (10 points) Compute the average of the two
grades and print to the console window a final message communicating the
result of this calculation.
Note that the communication with the user will occur in the console window
and the drawing in a separate window. Do not let this confuse you.
Part 2: How was it?
(5 points) Create a short ReadMe Word or text file (ReadMe.doc or
ReadMe.txt) containing the following information:
- Your full name
- Class, section, and homework number
- A couple of paragraphs describing the main difficulties
encountered when completing this assignment as well as the aspect that was
the most fun.
As always, you must submit the assignment using the online homework
submission system on the COL site. Create a .zip file with the source
code (i.e. .java) file from Part 1
and the readme file from Part 2 and upload this file to the COL site. The
.zip file should be called yourLastName.zip where yourLastName is your last
The assignment is worth 100 points. The points for each part are