animated house. import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; /** * * @author * */ public class MyHouse {    public static void main(String[] args) {        DrawingPanel panel = new DrawingPanel(750, 500);        panel.setBackground (new Color(65,105,225));

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Modify this code to make a moving animated house.

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;

/**
*
* @author
*
*/
public class MyHouse {

   public static void main(String[] args) {

       DrawingPanel panel = new DrawingPanel(750, 500);
       panel.setBackground (new Color(65,105,225));
       Graphics g = panel.getGraphics();
      
       background(g);
   house (g);
   houseRoof (g);
   lawnRoof (g);
   windows (g);
   windowsframes (g);
   chimney(g);
  
}
   /**
   *
   * @param g
   */
   static public void background(Graphics g)
   {
   g.setColor (new Color (225,225,225));//clouds   
   g.fillOval (14,37,170,55);
   g.fillOval (21,21,160,50);
   g.fillOval (351,51,170,55);
   g.fillOval (356,36,160,50);   
  
   }
     

   static public void house (Graphics g)
{
g.setColor (new Color(139,69,19)); //house
g.fillRect (100,250,400,200);
g.fillRect (499,320,200,130);
g.setColor(new Color(190,190,190)); //chimney and doors
g.fillRect (160,150,60,90);
g.fillRect (245,380,110,70);
g.fillRect (508,350,180,100);
g.setColor (new Color(186,134,11)); //door handle
g.fillOval (282,412,10,10);
g.fillOval (307,412,10,10);

}

   static public void houseRoof (Graphics g)
{
g.setColor(new Color(190,190,190)); //house roof
int x[] = {98,300,501};
int y[] = {250,130,250};
g.fillPolygon(x,y,3);
}

static public void lawnRoof (Graphics g)
{
g.setColor (new Color(190,190,190)); //lawn roof
int x[] = {499,499,700};
int y[] = {320,249,320};
g.fillPolygon(x,y,3);
}


static public void windows (Graphics g)
{ g.setColor (Color.orange); //windows outer frame effect
g.fillOval (521,350,68,31);
g.fillOval (606,350,68,31);
g.fillRect (121,261,78,78);
g.fillRect (401,261,78,78);
g.setColor (Color.white); //windows with frames
g.fillRect (125,265,70,70);
g.fillRect (405,265,70,70);
  
}

static public void windowsframes (Graphics g)
{
g.setColor (new Color(139,69,19)); // door sections
g.fillRect (299,380,2,70);
g.fillRect (507,382,180,2);
g.fillRect (507,417,180,2);
g.setColor (new Color(186,134,11)); //inner frame effect
g.fillRect (156,265,5,70);
g.fillRect (436,265,5,70);
g.fillRect (124,298,70,5);
g.fillRect (404,298,70,5);
g.fillRect (244,375,110,5); //door frame
g.fillRect (241,375,5,75);
g.fillRect (354,375,5,75);
g.fillRect (508,345,180,5);
g.fillRect (505,345,5,105);
g.fillRect (684,345,5,105);
}

static public void chimney (Graphics g)
{
g.setColor (new Color(210,180,140)); //smoke for chimney
g.fillOval (162,106,36,44);
g.fillOval (172,96,36,44);
g.fillOval (162,86,36,44);
g.fillOval (172,36,36,44);
g.fillOval (162,26,36,44);
g.fillOval (172,16,36,44);

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education