Please! I need help with this assignment Java language Objectives: Instantiating
ID: 3817844 • Letter: P
Question
Please! I need help with this assignment
Java language
Objectives:
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, you are going to 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 units
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.
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 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:
Next 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 has its own number of rows, which is also the same number of blocks in the bottom row.
The triangle properties:
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 should use parameters wisely so it can be used to draw a triangle 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.
NOTE: feel free to choose your own background color and color for the lower left portion of the blocks. I do want the upper right portion to 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 previously:
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!
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) 15Explanation / Answer
The tree structure of the venture is this:
.
manufacture
src
assaults
drivers
Driver.java
special cases
MyException.java
There are two exceptional indexes - work for containing gathered classes and src to contain source documents (could be in various subdirectories - bundles).
The accompanying order aggregates the entire venture and puts the outcome into the construct index.
javac - sourcepath src - d construct src/**/*.java
The - sourcepath src determines index src as where all the source can be found by the compiler. The - d fabricate alternatives advises the compiler where to put the incorporated records.
Alternative src/**/*.java advises the compiler what documents to really assemble. In this particular case it advises javac to look two levels down and pick all *.java at that level.
In the event that there are *.java records at various levels than a rundown of documents should be indicated. For this, one could make such posting as an outside document and pass this records as in information alternative for javac.
Here is the means by which this should be possible under Linux/Unix:
find - name "*.java" > source.txt
The above order makes document source.txt that contains full ways for the discovered *.java records. For this case it contains:
./src/drivers/Driver.java
./src/special cases/MyException.java
So as to aggregate the venture with the rundown of source documents flushed into source.txt, the accompanying charge can be utilized:
javac - d manufacture @source.txt
It would be ideal if you take note of that @source.txt determined toward the end that advises the compiler where to search for a rundown of source documents. It would be ideal if you additionally take note of that the - sourcepath alternative can be discarded.
Here is the way the registry structure changed subsequent to running the above order.
.
assemble
drivers
Driver.class
exemptions
MyException.class
src
assaults
drivers
Driver.java
exemptions
MyException.java
As can be watched the assemble index now contains the gathered class documents in particular bundles.
Furthermore, in the event that you'd jump at the chance to run it, accepting, for instance, that Driver has technique principle, the accompanying summon executes the program.
java - cp .:build:**/*.class drivers.Driver
It would be ideal if you take note of that record separator : (colon) is utilized under Unix, for Windows transform it to ; (semicolon).