PX_Lastname_DrawHouse Specification

Specification Sheet

Program Name: PX_Lastname_HouseDrawing

Program Purpose: This Java program uses AWT and Swing to create a graphical representation of a simple house. The house consists of a rectangular base, a triangular roof, and a rectangular door. The design includes colors and optional outlines for clarity.

Features:

Components Used:

User Interface:

The program opens a 600x500-pixel window displaying the house. The window is titled "House Drawing."

Limitations:

Dependencies:

Requires Java Development Kit (JDK) with Swing and AWT libraries (included by default).

Pseudo Code

1. Import Libraries:
   - Import AWT and Swing classes for GUI creation and rendering.

2. Define the `PX_Lastname_HouseDrawing` Class:
   - Extend `JPanel` to enable custom drawing.
   - Override the `paintComponent(Graphics g)` method.

3. Setup the Drawing Panel:
   - Cast the `Graphics` object to `Graphics2D` for advanced rendering.
   - Set the drawing colors for each component.

4. Draw Components:
   - **House Base**:
     - Use `fillRect(x, y, width, height)` to draw a blue rectangle.
   - **Roof**:
     - Define the x and y coordinates of the triangular roof's vertices.
     - Use `fillPolygon(int[] xPoints, int[] yPoints, int nPoints)` to fill the triangle with red.
   - **Door**:
     - Use `fillRect(x, y, width, height)` to draw a dark gray rectangle for the door.
   - **Optional Outlines**:
     - Use `drawRect` and `drawPolygon` to add black outlines around the house base, roof, and door.

5. Create Main Application Window:
   - Create a `JFrame` with a title "House Drawing."
   - Add an instance of `PX_Lastname_HouseDrawing` as the drawing panel.
   - Set the frame size to 600x500 pixels.
   - Configure the frame to exit when closed.
   - Display the frame.

6. Run the Program:
   - Launch the `main` method to render the window with the house drawing.
        

Below see a sample program that ONLY provide sample code. (not the solution)

Below is the intended output I WANT.

In this lesson, you will write a program running Java.
We will be drawing.
            
            You will drop off 5 files into Google Classroom:
            • Your files will be: (Remember the python program is dropped off first.)
                • PX_lastname_DrawHouse.java (Java program)
                • PX_lastname_DrawHouse.png (Screenshot inside Eclipse)
                • PX_lastname_DrawHouse.mp4 (Video running the program)

            
                 If you do not understand this assignment,
                 ask Mr. Cusack and/or attend tutorials.