Question

(JAVA) Use the basic shapes you learned in this chapter to draw a house. Be sure...

(JAVA)

Use the basic shapes you learned in this chapter to draw a house. Be sure to include at
least two windows and a door
code so far:

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;

public class House extends Application {
@Override
public void start(Stage stage) {
//Creating a Path
Path path = new Path();
Rectangle = new rectangle(20,220);
//Moving to the starting point
MoveTo moveTo = new MoveTo(160,20);
  
//Creating 1st line
LineTo line1 = new LineTo(20,220 );
LineTo Line2= new LineTo(310,220);
LineTo Line3= new LineTo(160,20);
  
Polygon paralllogram = new Polygon();
parallelogram.getPoints().addAll(20,220,310,20,20,420,510,20);


//Adding all the elements to the path
path.getElements().add(moveTo);
path.getElements().addAll(line1, Line2, Line3);

//Creating a Group object
Group root = new Group(path);

//Creating a scene object
Scene scene = new Scene(root, 600, 300);
  
//Setting title to the Stage
stage.setTitle("Drawing an arc through a path");
  
//Adding scene to the stage
stage.setScene(scene);
  
//Displaying the contents of the stage
stage.show();   
}
public static void main(String args[]){
launch(args);
}
}   

Homework Answers

Answer #1


import java.applet.Applet;
import java.awt.Graphics;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author Deepak
*/

public class house extends Applet
{
public void paint(Graphics gp)
{
int [] x = {150, 300, 225};
int [] y = {150, 150, 25};
gp.drawRect(150, 150, 150, 200); //House //rectangle
gp.drawRect(200, 200, 50, 150); // Door //rectangle
gp.drawRect(170, 200, 20, 40); // window1 //rectangle
gp.drawRect(260, 200, 20, 40); // window2 //rectangle
gp.drawOval(200, 75, 50, 50); // Up window //oval
gp.drawPolygon(x, y, 3); // Top //polygon
this.setSize(500, 400);
}
}


Using the basic shapes this is done in an easy way.For any queries pls comment

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
package Week7_Quiz; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.scene.control.Label;
package Week7_Quiz; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.scene.control.Label; import javafx.stage.Stage; public class Week7_Quiz extends Application { private TextField tf1; private Label stckr; private int revrsdNum; private Button btn; int num = 0; int reverse; public static void main(String[] args) {       launch (args); } @Override public void start(Stage stage) throws Exception { tf1 = new TextField(); tf1.setLayoutX(10); tf1.setLayoutY(50);    stckr =new Label ("Result: "); stckr.setLayoutX(12); stckr.setLayoutY(100);    btn = new Button("Reverse");...
Compile and execute the application. You will discover that is has a bug in it -...
Compile and execute the application. You will discover that is has a bug in it - the filled checkbox has no effect - filled shapes are not drawn. Your first task is to debug the starter application so that it correctly draws filled shapes. The bug can be corrected with three characters at one location in the code. Java 2D introduces many new capabilities for creating unique and impressive graphics. We’ll add a small subset of these features to the...
Hi, I am trying to create an XML JTree viewer using the DOM parser instead of...
Hi, I am trying to create an XML JTree viewer using the DOM parser instead of the SAX parser, I am having trouble changing my code in order to utilize the DOM parser to extract the XML data into the tree structure. Would you be able to explain what changes should be made to the code in order to use the DOM parser instead of the SAX parser? // Java Packages //      import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import...
Complete the redblacktree in Java. Add a public boolean isBlack field to the Node inner class....
Complete the redblacktree in Java. Add a public boolean isBlack field to the Node inner class. Make every Node object have a false isBlack field, all new node is red by default. In the end of the insert method, set the root node of your red black tree to be black. Implement the rotate() and recolor() functions, and create tests for them in a separate class. import java.util.LinkedList; public class BinarySearchTree<T extends Comparable<T>> { protected static class Node<T> { public...
IN JAVA!! You may be working with a programming language that has arrays, but not nodes....
IN JAVA!! You may be working with a programming language that has arrays, but not nodes. In this case you will need to save your BST in a two dimensional array. In this lab you will write a program to create a BST modelled as a two-dimensional array. The output from your program will be a two-dimensional array.   THEN: practice creating another array-based BST using integers of your choice. Once you have figured out your algorithm you will be able...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...
Java Program: You will be inserting values into a generic tree, then printing the values inorder,...
Java Program: You will be inserting values into a generic tree, then printing the values inorder, as well as printing the minimum and maximum values in the tree. Given main(), write the methods in the 'BSTree' class specified by the // TODO: sections. There are 5 TODOs in all to complete. Ex: If the input is like ferment bought tasty can making apples super improving juice wine -1 the output should be: Enter the words on separate lines to insert...
JAVA please Arrays are a very powerful data structure with which you must become very familiar....
JAVA please Arrays are a very powerful data structure with which you must become very familiar. Arrays hold more than one object. The objects must be of the same type. If the array is an integer array then all the objects in the array must be integers. The object in the array is associated with an integer index which can be used to locate the object. The first object of the array has index 0. There are many problems where...
this is the book name. Data Structures and Abstractions with Java 1) Description: The sample programs...
this is the book name. Data Structures and Abstractions with Java 1) Description: The sample programs in Chapter 1 of your textbook are not complete. They are used for illustration purpose only. The implementation of Listing 1-1 on page 39 is explained in Chapter 2. And, in order to see the result of using it, we will need the following set of files: i. BagInteface.java – the specification only. ii. ArrayBag.java – the implementation of BagInerface.java. iii. ArrayBagDemo.java – a...
Task 1: You will modify the add method in the LinkedBag class.Add a second parameter to...
Task 1: You will modify the add method in the LinkedBag class.Add a second parameter to the method header that will be a boolean variable: public boolean add(T newEntry, boolean sorted) The modification to the add method will makeit possible toadd new entriesto the beginning of the list, as it does now, but also to add new entries in sorted order. The sorted parameter if set to false will result in the existing functionality being executed (it will add the...