Share
Explore BrainMass

What is the length of the line being drawn?
g.drawLine (50, 20, 50, 350);
What is the (x, y) coordinate of the lower-right corner of the rectangle being drawn?
g.drawRect (10, 20, 250, 350);
_______________________________________________________________________________
Fill in the code
This code sets the current color to red
// assume you have a Graphics object named g
// code goes here
This code draws the string "Fill in the Code" with the lower-left corner of the first character (the f) being coordinate (100, 250).
// assume you have a graphics object called g
// code goes here
Identifying Errors in Code
Where is the error in this code sequence?
// we are inside method paint
g.drawString ('find the bug', 100, 200);
Where is the error in this code sequence?
// we are inside method paint
g.setColor(green);

#### Solution Preview

What is the length of the line being drawn?
g.drawLine (50, 20, 50, 350);
ans: length=sqrt[(50-50)^2+(350-20)^2]=330

What is the (x, y) coordinate of the lower-right corner of the rectangle being drawn?
g.drawRect (10, 20, 250, 350);
ans: (x, y) coordinate = (10+250, 20-350) = (260, ...

#### Solution Summary

The solution gives detailed guide to some coding questions. I provide both answers and explanations.

\$2.19