go to previous page   go to home page   go to next page

Answer:

All you have to do is copy the information to the blanks.


House Rectangles

Here is the applet with all the blanks filled in. With skillful use of the text editor, much of this filling in is easily done using "copy" and "paste".


 class HousePanel extends JPanel
{
  final int width  = 350, height = 250;
  
  final int houseX =  50, houseY = 100, houseW = 150, houseH = 100 ;
  final int doorX  = 120, doorY  = 150, doorW  =  20, doorH  =  50 ;
  final int lWindX =  75, lWindY = 140, lWindW =  25, lWindH =  40 ;
  final int rWindX = 160, rWindY = 140, rWindW =  25, rWindH =  40 ;
  final int trunkX = 260, trunkY =  65, trunkW =  10, trunkH = 100 ;

  public HousePanel()
  {
    setPreferredSize( new Dimension( width, height) );
    setBackground( Color.WHITE);   
  }
  
  public void paintComponent ( Graphics gr )
  { 
     super.paintComponent( gr );
     gr.setColor( Color.ORANGE );                    // there is no Color brown
     gr.drawRect( houseX , houseY , houseW, houseH); // house
     gr.drawRect( doorX  , doorY  , doorW , doorH ); // door
     gr.drawRect( lWindX , lWindY , lWindW, lWindH); // lwind
     gr.drawRect( rWindX , rWindY , rWindW, rWindH); // rwind
     gr.drawRect( trunkX , trunkY , trunkW, trunkH); // trunk
  }
}

The program productes this incomplete drawing:

House picture, rectangles only

QUESTION 5:

It is tedious to read off all those coordinates from graph paper. It would be better to have the program calculate some of them. You want the door horizontally centered in the house.