Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

Anyone knows what is the best way to resolve the Exercise 11, Chapter 3 of the book: The Art and Science of Java?

Computer Science
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SIGN UP FOR FREE
It might help to post the question here.
Give few questions dude dont have book.
If u Have ebook for that please upload or give link to download from site

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

11. Exercise 4 in Chapter 2 asks you to write a graphics program that produces a diagram of a simple frame house. If you wanted to make (the DrawHouse program easy to change, what named constants should you define to provide the necessary flexibility? Rewrite the program so that it uses these named constants rather than explicit coordinate values. Here it is the DrawHouse: import acm.graphics.*; import acm.program.*; public class JHouse extends GraphicsProgram{ public void run(){ GRect rectWalls = new GRect(((getWidth() - 300)/2), ((getHeight()-120)/2), 300, 120); GRect rectDoor = new GRect(((getWidth() - 50)/2), ((getHeight()-80)/2+20), 50, 80); GRect windLeft = new GRect(((getWidth() - 40)/2-90), ((getHeight()-40)/2), 40, 40); GRect windRight = new GRect(((getWidth() - 40)/2+90), ((getHeight()-40)/2), 40, 40); GLine roofRight = new GLine(527,177,370,50); GLine roofLeft = new GLine(228,177,369,50); GLine windFrameR = new GLine(287,255,287,216); GLine windFrameL = new GLine(467,255,467,216); GOval doorHandle = new GOval(387,255,7,7); add(rectWalls); add(rectDoor); add(windLeft); add(windRight); add(roofRight); add(roofLeft); add(windFrameR); add(windFrameL); add(doorHandle); } }
And here is what I came up with: Can you guys tell me if there is a better way to resolve this? I appreciate if you post the explanation as well, so I can understand how to think. Thanks import acm.graphics.*; import acm.program.*; public class JHouseRevised extends GraphicsProgram{ public void run(){ add(new GRect(((getWidth()-HOUSE_SIZE)/2),((getHeight()-HOUSE_SIZE+ROOF_SIZE)/2),HOUSE_SIZE,HOUSE_SIZE/2)); add(new GRect(((getWidth()-(DOOR_SIZE/2))/2),((getHeight()-DOOR_SIZE)/2+(DOOR_SIZE/2)),DOOR_SIZE/2,DOOR_SIZE)); add(new GRect(((getWidth()-(DOOR_SIZE/2))/2-90),((getHeight()-(DOOR_SIZE/2))/2),(DOOR_SIZE/2),(DOOR_SIZE/2))); add(new GRect(((getWidth()-(DOOR_SIZE/2))/2+90),((getHeight()-(DOOR_SIZE/2))/2),(DOOR_SIZE/2),(DOOR_SIZE/2))); add(new GLine(((getWidth()+HOUSE_SIZE)/2),((getHeight()+(ROOF_SIZE-HOUSE_SIZE))/2),(getWidth()/2),(getHeight()-(HOUSE_SIZE*2)+ROOF_SIZE))); add(new GLine(((getWidth()-HOUSE_SIZE)/2),((getHeight()+(ROOF_SIZE-HOUSE_SIZE))/2),(getWidth()/2),(getHeight()-(HOUSE_SIZE*2)+ROOF_SIZE))); add(new GLine((getWidth()/2-(HOUSE_SIZE/4)-15),((getHeight()/2)+DOOR_SIZE/4),(getWidth()/2-(HOUSE_SIZE/4)-15),((getHeight()/2)-DOOR_SIZE/4))); add(new GLine((getWidth()/2+(HOUSE_SIZE/4)+15),((getHeight()/2)-DOOR_SIZE/4),(getWidth()/2+(HOUSE_SIZE/4)+15),((getHeight()/2)+DOOR_SIZE/4))); add(new GOval(((getWidth()-DOOR_HANDLE)/2+(DOOR_SIZE/6)),(getHeight()/2+(DOOR_SIZE/2)),DOOR_HANDLE,DOOR_HANDLE)); } /*Constant*/ private static final int HOUSE_SIZE = 300; private static final int ROOF_SIZE = 200; private static final int DOOR_SIZE = 100; private static final int DOOR_HANDLE = 7; }

Not the answer you are looking for?

Search for more explanations.

Ask your own question