Question: !!!! Need help with Computer Science problem The only import that is allowed is java.awt.* Drawings Please save your .project in either a .zip or

!!!! Need help with Computer Science problem

The only import that is allowed is java.awt.*

Drawings

Please save your .project in either a .zip or .jar file and submit that.

Objectives:

Writing client code - Instantiating objects, sending messages, and managing multiple files

Continued practice with loops and decomposition

For this assignment you'll be using the DrawingPanel.java class provided with the textbook. You will need to have this file in the same BlueJ folder as your solution. There are two parts to this assignment: Part 1: For the first part, write a method named part1() to draw any figure you'd like on the DrawingPanel. You may draw any image that

is at least 200 x 200 pixels

contains at least three different draw and/or fill messages to the Graphics object (using at least two different shapes)

uses at least two distinct colors,

is your own work

and is not similar to the image for Part 2.

You must also display your name on the DrawingPanel, using the method that writes a String to the Graphics object.

Call this method from main(). You may decompose this solution, but it is not a requirement. Part 2: In the second part of the assignment your program must produce the image below containing these elements.

This image has a structure. First, notice there are individual blocks that are half gray and half white. These are drawn with different sizes at different locations.

Each block is made up of levels that look like stairs. In the center of each block you see 4 squares. Each of these squares is 8 x 8 pixels. This is level 1.From the center, the block expands with additional levels in 4 directions that look like stairs. One dimension of each of these stair steps is 8 pixels. The other dimension grows with each level.

The block properties:

Description center point (x, y) number of levels
small block (upper left) (60, 60) 3
medium block (lower center) (525, 650) 5
large block (far right) (800, 525) 15

Also in the image you see triangular shapes made up of these blocks. They are sized and positioned based on the data of the top block. Each triangular figure has its own number of rows, which is also the same number of blocks in the bottom row.

The triangular figure properties:

Description Properties of top block number of rows
upper left figure Center: (300, 225) Levels: 12 3
lower left figure Center: (250, 575) Levels: 6 5
far right figure Center: (790, 80) Levels: 4 6

The overall panel has size 1000 x 850.

Implementation Requirements:

You should have two methods, one to draw a block at any location with any number of levels, and another method to draw a triangle, based on the information about the top block and with any number of rows.

Your method design for the block should use parameters wisely so it can be used to draw figures of any size in any location. If you'd like, consider using the Point class from the Java API (though this isn't a requirement).

Your method design for the triangle figure should use parameters wisely so it can be used to draw a figure of any size in any location. Do not make your method more flexible than this. In otherwords, the parameters should be the minimum needed to draw the specific design.

Feel free to choose your own background color and color for the lower left portion of the blocks. The upper right portion of each block must be white.

Since we will need access to the Graphics object's methods and the Color constants, you need to include an import statement for its package. Include the following import statement at the beginning of your class file:

import java.awt.*; Put the complete solution for part 2 in its own method definition named part2() and call this method from main(). The main method should only contain 2 methods calls. When you are finished with both parts and you call main, 2 DrawingPanels should be displayed (don't worry if they open on top of one another).

Other Requirements

Make good decomposition choices.

You are expected you to use good style (indentation, commenting, good variable names, etc) and to include a block comment for the class and for each method. Please see the documentation guidelines posted on our homepage.

You do not need to create class constants for the values used to call your methods. However, it should be a simple code change for a programmer to modify the width constant.

Use algorithm comments effectively.

For this assignment you are limited to the language features in Chapters 1 through 3G of the textbook. In particular, do not use if statements.

Make sure to document each of your methods (except main()) with the information discussed:

description of the method's job or outcome

description of the parameters

return (if there is any)

Grading

/3 part 1 (make sure you've followed all the requirements) /12 part 2 (this includes both the image displayed and the design of your solution.) /5 comments, style

Good Luck!

DrawingPanel File View Help DrawingPanel File View Help

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!