anonymous
  • anonymous
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
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
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.
katieb
  • katieb
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
It might help to post the question here.
anonymous
  • anonymous
Give few questions dude dont have book.
anonymous
  • anonymous
If u Have ebook for that please upload or give link to download from site

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
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); } }
anonymous
  • anonymous
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; }

Looking for something else?

Not the answer you are looking for? Search for more explanations.