Eine gute Antwort wäre:

You should get something like this:

House        --- ( 65, 100) width=110, height=110
Door         --- (120, 165) width= 25, height= 40
Left Window  --- ( 90, 115) width= 30, height= 30
Right Window --- (130, 115) width= 30, height= 30
Tree Trunk   --- (255, 100) width= 10, height=100

Start on the Applet

With this information, we can start coding the applet.

import java.applet.Applet;
import java.awt.*;

// assume that the drawing area is 350 by 250
public class HouseRectangles extends Applet
{
  final int width = 350, height = 250;
  final int houseX = ________, houseY = ______, houseW = _______, houseH = ______ ;
  final int doorX  = ________, doorY  = ______, doorW  = _______, doorH  = ______ ;
  final int lWindX = ________, lWindY = ______, lWindW = _______, lWindH = ______ ;
  final int rWindX = ________, rWindY = ______, rWindW = _______, rWindH = ______ ;
  final int trunkX = ________, trunkY = ______, trunkW = _______, trunkH = ______ ;

  public void paint ( Graphics gr )
  {

     gr.drawRect(                                  ); // house
     gr.drawRect(                                  ); // door
     gr.drawRect(                                  ); // lwind
     gr.drawRect(                                  ); // rwind
     gr.drawRect(                                  ); // trunk
  }
}

You may think that it would be just as easy to put the numbers directly in the various called to the drawRect() method, but this is not so. If you need to adjust things later on, it will be very useful to have names for the various values you wish to change.

FRAGE 4:

Fill in the 40 (!) blanks.

Inhaltsverzeichnis