+1 (315) 557-6473 

Creating a House Project Help Involving Java.

The following Creating a House Project Help demonstrates how to write a program for creating a house with specified shapes in Java. Our Java Homework Help programmer wrote an accurate program that meets all the underlying house's requirements.
creating a house project help
Parts Of the House
1. 1 arc
2. 2 different polygons (must be at least 3-sided or more than 4 sided)
3. 1 PolyLine with a minimum of 4 coordinate pairs
4. 1 rounded rectangle
5. 1 QuadCurve 2D
Creating a House Project Help Involving Java
6. 1 CubicCurve 2D 
Creating a House Project Help Involving Java
Using Absolute coding techniques with the swing API.
7. 6 (at least) other shapes of your choice
You must use absolute coding techniques with the swing API. Your picture must be centered on any screen and shouldn't exceed 1440 by 800 (size). The size of the JFrame should not be changeable by the user. The JFrame must be titled. The Java program mist close when the JFrame is closed.
Solution
import javax.swing.*;
import java.awt.*;
import java.awt.geom.CubicCurve2D;
import java.awt.geom.QuadCurve2D;
public class CanvasFrame extends JFrame {
    public CanvasFrame() {
        setTitle("My canvas");
        getContentPane().add(new Canvas());
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setPreferredSize(new Dimension( 800, 600));
        setResizable(false);
        setVisible(true);
        pack();
    }
    private static class Canvas extends JPanel {
        @Override
        public void paint(Graphics g) {
            // drawing background
            g.setColor(Color.BLUE);
            g.fillRect(0, 0, getWidth(), getHeight());
            // drawing field
            g.setColor(Color.GREEN);
            g.fillArc(-getWidth()/2, 400, 2*getWidth(), 400, 0, 180);
            // drawing house
            int[] housePointsX = new int[]{250, 250, 550, 550};
            int[] housePointsY = new int[]{500, 200, 200, 500};
            g.setColor(Color.YELLOW);
            g.fillPolygon(new Polygon(housePointsX, housePointsY, 4));
            // drawing roof
            int[] roofPointsX = new int[]{220, 400, 580};
            int[] roofPointsY = new int[]{220, 100, 220};
            g.setColor(new Color(128, 64, 0, 255));
            g.fillPolygon(new Polygon(roofPointsX, roofPointsY, 3));
            // drawing door
            g.fillRect(450, 290, 80, 200);
            // drawing door sections
            g.setColor(Color.WHITE);
            int[] doorSectionsX = new int[]{460, 460, 520, 520, 460, 460, 520, 520};
            int[] doorSectionsY = new int[]{400, 300, 300, 400, 400, 480, 480 ,400};
            g.drawPolyline(doorSectionsX, doorSectionsY, 8);
            // drawing window
            g.setColor(Color.CYAN);
            g.fillRoundRect(280, 290, 100, 100, 20, 20);
// g.setColor(Color.RED);
// QuadCurve2D quad = new QuadCurve2D.Double(100, 100, 100, 400, 200, 100);
// ((Graphics2D) g).draw(quad);
            // drawing chimney
            g.setColor(Color.GRAY);
            g.fillRect(280, 120, 30, 80);
            // drawing smoke
            g.setColor(Color.LIGHT_GRAY);
            QuadCurve2D quad1 = new QuadCurve2D.Double(285, 115, 275, 55, 270, 70);
            ((Graphics2D) g).draw(quad1);
            QuadCurve2D quad2 = new QuadCurve2D.Double(305, 115, 315, 55, 320, 70);
            ((Graphics2D) g).draw(quad2);
            CubicCurve2D cubic = new CubicCurve2D.Double(295, 115, 285, 100, 305, 85, 295, 70);
            ((Graphics2D) g).draw(cubic);
        }
    }
    public static void main(String[] args) {
        SwingUtilities.invokeLater(CanvasFrame::new);
    }
}
Related Blogs

Java tutors in the USAJava is a computing language designed for the development of desktop and mobile applications, embedded systems, and the processing of big data. Introduced in 1995, Java is so much like C and C + + but easier to use because it enforces the object-oriented programming model. One ...

2020-07-25
Read More

Are You Troubled with Your Java Programming Homework?Java programming language was derived from C but is more flexible and compatible with multiple platforms. Java’s true power lies within people’s ability to manipulate the objects and variables within a program, which is why it is considered an obj...

2020-08-12
Read More

Why You May Seriously Need Help With Java Programming Homework?How well are you conversant with Java programming? Given Java homework, can you handle it correctly for impressive results? Well, if you can not, there is a need to seek help with the Java programming homework. Also, even after get...

2020-08-12
Read More

Why C# Programming Homework Help Is Better Than JavaThere are a lot of similarities between Java and C#, and the responsibility of this can be placed on Sun. Microsoft used to have its own implementation of Java which had some changes so that you could access Windows fully but Sun sued and so Micros...

2020-08-12
Read More

Improving Your Java Coding Skills by Learning How to DebugIt is no secret that most students spend a lot of time debugging rather than writing their Java code. In most universities and colleges, professors will only teach you the concepts of coding in Java and not how to fix the defects in your soft...

2020-08-12
Read More