//Applet Program to draw a House
// Developed by Ahlam Ansari
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Polygon;
/*<applet code=Houseref.class width=600 height=600></applet>*/
public class Houseref extends Applet
{
public void paint (Graphics page)
{
Polygon poly = new Polygon(); // Roof Polygon
poly.addPoint (50,90);
poly.addPoint (150, 50);
poly.addPoint (250, 90);
page.setColor (new Color(218,165,32)); // Custom brown color
page.fillPolygon (poly);
page.setColor (Color.black);
page.drawLine (50, 90, 150, 50); // Roof outline
page.drawLine (150, 50, 250, 90);
page.setColor (Color.yellow);
page.fillRect (50, 90, 200, 100); // House base with houseColor
page.setColor (Color.black);
page.drawRect (50, 90, 200, 100); // House outline
page.setColor (Color.black);
page.fillRect (75, 110, 30, 25); // Window 1
page.fillRect (190, 110, 30, 25); // Window 2
page.setColor (Color.blue);
page.drawLine (75, 123, 105, 123); // Window Frame 1
page.drawLine (89, 110, 89, 134);
page.fillRect (70, 110, 5, 25); // Shutter 1
page.fillRect (105, 110, 5, 25); // Shutter 2
page.drawLine (75+115, 123, 105+115, 123); // Window Frame 2
page.drawLine (89+115, 110, 89+115, 134);
page.fillRect (70+115, 110, 5, 25); // Shutter 3
page.fillRect (105+115, 110, 5, 25); // Shutter 4
page.setColor (Color.blue);
page.fillRect (130, 150, 35, 40); // Door
page.setColor (Color.red);
page.fillOval (155, 170, 4, 4); // Door knob
}
}
/*
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>javac Houseref.java
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>appletviewer Houseref.java
*/
// Developed by Ahlam Ansari
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Polygon;
/*<applet code=Houseref.class width=600 height=600></applet>*/
public class Houseref extends Applet
{
public void paint (Graphics page)
{
Polygon poly = new Polygon(); // Roof Polygon
poly.addPoint (50,90);
poly.addPoint (150, 50);
poly.addPoint (250, 90);
page.setColor (new Color(218,165,32)); // Custom brown color
page.fillPolygon (poly);
page.setColor (Color.black);
page.drawLine (50, 90, 150, 50); // Roof outline
page.drawLine (150, 50, 250, 90);
page.setColor (Color.yellow);
page.fillRect (50, 90, 200, 100); // House base with houseColor
page.setColor (Color.black);
page.drawRect (50, 90, 200, 100); // House outline
page.setColor (Color.black);
page.fillRect (75, 110, 30, 25); // Window 1
page.fillRect (190, 110, 30, 25); // Window 2
page.setColor (Color.blue);
page.drawLine (75, 123, 105, 123); // Window Frame 1
page.drawLine (89, 110, 89, 134);
page.fillRect (70, 110, 5, 25); // Shutter 1
page.fillRect (105, 110, 5, 25); // Shutter 2
page.drawLine (75+115, 123, 105+115, 123); // Window Frame 2
page.drawLine (89+115, 110, 89+115, 134);
page.fillRect (70+115, 110, 5, 25); // Shutter 3
page.fillRect (105+115, 110, 5, 25); // Shutter 4
page.setColor (Color.blue);
page.fillRect (130, 150, 35, 40); // Door
page.setColor (Color.red);
page.fillOval (155, 170, 4, 4); // Door knob
}
}
/*
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>javac Houseref.java
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>appletviewer Houseref.java
*/
good
ReplyDelete