
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);
}

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- 1 import java.util.Random; 2 3 4 5 6- 7 8 9 10 11 12 ▼ import java.util.StringJoiner; public class preLabC { public static MathVector myMethod(int[] testValues) { // Create an object of type "MathVector". // return the Math Vector Object back to the testing script. return VectorObject; 13 14 15 } } ▸ Comments Description The MathVector.java file contains a class (Math Vector). This class allows you to create objects in your program that can contain vectors (a 1D array) and perform actions on those vectors. This is useful for doing math operations like you would in your linear algebra class. Your method should evaluate against two tests. What do you need to do in this exercise? You need to create an "instance" of the MathVector object, VectorObject, in your method. If you do this correctly, your method will accept a 1D array of integers, testValues, feed it into the VectorObject and then return the VectorObject. If you look in the file MathVector.java you'll see that this is one way in…arrow_forwardHow do I make the code output Java? import java.util.Arrays; public class Movie { String movieName; int numMinutes; boolean isKidFriendly; int numCastMembers; String castMembers[] = new String[10]; // Non-parameterized constructor public Movie() { this.movieName = "Flick"; this.numMinutes = 0; this.isKidFriendly = false; this.numCastMembers = 0; } // Parameterized constructor public Movie(String movieName, int numMinutes, boolean isKidFriendly, int numCastMembers, String[] castMembers) { this.movieName = movieName; this.numMinutes = numMinutes; this.isKidFriendly = isKidFriendly; this.numCastMembers = numCastMembers; this.castMembers = castMembers; } // getter and setters public String getMovieName() { return movieName; } public void setMovieName(String movieName) { this.movieName = movieName; } public int getNumMinutes() { return numMinutes; } public void setNumMinutes(int numMinutes) { this.numMinutes = numMinutes; } public boolean isKidFriendly() { return…arrow_forwardPlease complete and check my code in Java (eclipse). Complete the instructions (please see images). Please add comments. package HW5;enum Color { YELLOW, ORANGE, RED, PURPLE;} public class Fruit{ private Color color; private int calories; private double pricePerPound; protected static int numberOfFruits;//Constructor a default fruit object Fruit(){ numberOfFruits++; } Fruit(Color color, int calories, double pricePerPound){ this.color=color; this.calories=calories; this.pricePerPound= pricePerPound; numberOfFruits++; } /////generate getters & setterspublic Color getColor() { return color;}public void setColor(Color color) { this.color = color;}public int getCalories() { return calories;}public void setCalories(int calories) { this.calories = calories;}public double getPricePerPound() { return pricePerPound;}public void setPricePerPound(double pricePerPound) { this.pricePerPound = pricePerPound;}public static int…arrow_forward
- Assume class ArrayStack has been deńned using the implementation in your textbook and that myStack has been initialized so it is empty. Type the EXACT output of the following code segment. You may assume that the code compiles and executes without errors. ArrayStack my5tack; int i = 1; int j = 2; int k = 3; int n = 4; myStack.push (); myStack.push (k); i = my5tack.peek (0: myStack.pop (); myStack.push (n); k = myStack.peek (); myStack.pop (); my5tack.push (n); my5tack.push (1); myStack.push (k); while (Imy5tack.isEmpty () { i = my5tack.peek (); my5tack.pop (); cout << i<< ""; cout << endl;arrow_forwardPlease fill in all the code gaps if possible: (java) public class LinkedListNode { private Object date; private LinkedListNode next; // Constructor: public LinkedListNode (Object data) // You also need to define the getter and setter: public LinkedListNode getNext() public void setNext (LinkedListNode next) public Object getData() public void setData(Object data) }arrow_forwardQuestion & instructions can be found in images please see images first Starter code import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.text.DecimalFormat; public class GPACalculator extends JFrame{private JLabel gradeL, unitsL, emptyL; private JTextField gradeTF, unitsTF; private JButton addB, gpaB, resetB, exitB; private AddButtonHandler abHandler;private GPAButtonHandler cbHandler;private ResetButtonHandler rbHandler;private ExitButtonHandler ebHandler; private static final int WIDTH = 400;private static final int HEIGHT = 150; private static double totalUnits = 0.0; // total units takenprivate static double gradePoints = 0.0; // total grade points from those unitsprivate static double totalGPA = 0.0; // total GPA (gradePoints / totalUnits) //Constructorpublic GPACalculator(){//Create labelsgradeL = new JLabel("Enter your grade: ", SwingConstants.RIGHT);unitsL = new JLabel("Enter number of units: ", SwingConstants.RIGHT);emptyL = new…arrow_forward
- Please help me with this. I am really struggling Please help me modify my java matching with the image provide below or at least fix the errors import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Game extends JFrame implements ActionListener { int hallo[][] = {{4,6,2}, {1,4,3}, {5,5,1}, {2,3,6}}; int rows = 4; int cols = 3; JButton pics[] = new JButton[rows*cols]; public Game() { setSize(600,600); JPanel grid = new JPanel(new GridLayout(rows,cols)); int m = 0; for(int i = 0; iarrow_forwardimport bridges.base.ColorGrid;import bridges.base.Color;public class Scene {/* Creates a Scene with a maximum capacity of Marks andwith a background color.maxMarks: the maximum capacity of MarksbackgroundColor: the background color of this Scene*/public Scene(int maxMarks, Color backgroundColor) {}// returns true if the Scene has no room for additional Marksprivate boolean isFull() {return false;}/* Adds a Mark to this Scene. When drawn, the Markwill appear on top of the background and previously added Marksm: the Mark to add*/public void addMark(Mark m) {if (isFull()) throw new IllegalStateException("No room to add more Marks");}/*Helper method: deletes the Mark at an index.If no Marks have been previously deleted, the methoddeletes the ith Mark that was added (0 based).i: the index*/protected void deleteMark(int i) {}/*Deletes all Marks from this Scene thathave a given Colorc: the Color*/public void deleteMarksByColor(Color c) {}/* draws the Marks in this Scene over a background…arrow_forwardQ1: Write the Java code corresponding to the following UML diagram. The class School implements the interface Building. The method computeArea returns the area of the building as width * length. After that, add a testing class with a main method which defines an arrayList that contains three objects. From the main method, print the area of all the three objects. Building > + computeArea() : double + toString() : String School classroomNum: int width: double - length: double + School(classroomNum: int, width: double, length: double) + computeArea() : double + toString() : Stringarrow_forward
- Implement move the following way. public int[] walk(int... stepCounts) { // Implement the logic for walking the players returnnewint[0]; } public class WalkingBoardWithPlayers extends WalkingBoard{ privatePlayer[] players; privateintround; publicstaticfinalintSCORE_EACH_STEP=13; publicWalkingBoardWithPlayers(int[][] board, intplayerCount) { super(board); initPlayers(playerCount); } publicWalkingBoardWithPlayers(intsize, intplayerCount) { super(size); initPlayers(playerCount); } privatevoidinitPlayers(intplayerCount) { if(playerCount <2){ thrownewIllegalArgumentException("Player count must be at least 2"); } else { this.players=newPlayer[playerCount]; this.players[0] =newMadlyRotatingBuccaneer(); for (inti=1; i < playerCount; i++) { this.players[i] =newPlayer(); } } } package walking.game.player; import walking.game.util.Direction; public class Player{ privateintscore; protectedDirectiondirection=Direction.UP; publicPlayer() {} publicintgetScore() { return score; }…arrow_forwardWrite a java program to complete the following parts: Part-1: Create a class Car and perform the following: - Declare public instance variables (name, model, color) as (String, int, and String) respectively. - Define set() method to set a car's name, model, and color. Define show() method to print out the car's name, model, and color. Part-2: In the main method: Declare an array of the defined class Car with length 5. Create three objects from Car and add them into the array. Set the objects' values (name, model, color) using set method. Print out the object's values (name, model, color) using show method.arrow_forwardThis is in Java. The assignement is to create a class. I am confused on how to write de code for an array that is up to 5. Also I am confused regarding how to meet the requirements of the constructor. This is what I have. public class InventoryOnShelf { //fields private int[] itemOnShelfList []; private int size; public InventoryOnShelf() { }arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





