In: Computer Science
in a gui ' in java write a program that draws equal a simple fence with vertical, spaced slats backed by two boards. Behind the fence show a simple house support Make sure the in the und. house is visible between the slats in the fence.
import java.awt.*;
import java.applet.*;
public class Designandimplementation
{
public void paint (Graphics g)
{
house (g);
roof1 (g);
windows (g);
framing (g);
}
public void house (Graphics g)
{
g.setColor (Color.black);
g.fillRect (100,250,400,200);
g.setColor(Color.blue);
g.fillRect (245,380,110,70);
g.setColor (new Color(186,134,11));
g.fillOval (282,412,10,10);
g.fillOval (307,412,10,10);
}
public void roof1 (Graphics g)
{
g.setColor(Color.red);
int x[] = {98,300,501};
int y[] = {250,130,250};
g.fillPolygon(x,y,3);
}
public void windows (Graphics g)
{
g.setColor (Color.red);
g.fillRect (121,261,78,78);
g.fillRect (121,361,78,78);
g.fillRect (401,261,78,78);
g.fillRect (401,361,78,78);
g.setColor (Color.orange);
g.fillRect (125,265,70,70);
g.fillRect (125,365,70,70);
g.fillRect (405,265,70,70);
g.fillRect (405,365,70,70);
}
public void framing (Graphics g)
{
g.setColor (Color.red);
g.fillRect (298,380,2,70);
g.setColor (Color.red);
g.fillRect (157,265,5,70);
g.fillRect (157,365,5,70);
g.fillRect (437,265,5,70);
g.fillRect (438,365,5,70);
g.fillRect (125,298,70,5);
g.fillRect (125,398,70,5);
g.fillRect (405,298,70,5);
g.fillRect (405,398,70,5);
g.fillRect (245,375,110,5);
}
}