Java Program for Two Rectangle Interaction

Download Solution: Click to Download Solution
Solution File Name: JavaProgramTwoRectangleInteraction.docx
Unzip Password: prestobear.com

Problem:
This class to write a program that enables the user to specify the location and size of the rectangles
and displays whether the two rectangles intersect
Enable the user to point the mouse inside a rectangle and drag it.
As the rectangle is being dragged, the rectangle’s center coordinates in the text fields are updated.


1. DrawingPoint.java
/**
 * This class is to define point to draw a shape
 */
public class DrawingPoint {

}

2. DrawingRectangle.java

import javafx.scene.shape.Rectangle;

/**
 * This class extends the GeometricObject to draw the rectangle
 */
public class DrawingRectangle extends GeometricObject {

}

3. GeometricObject.java

/**
 * The class provided by the Java Book to draw the shape object
 */
public abstract class GeometricObject implements Comparable {

}

4. MainClass.java

import javafx.application.Application;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

/**
 *This class to write a program that enables the user to specify the location and size of the rectangles 
 *and displays whether the two rectangles intersect
 *Enable the user to point the mouse inside a rectangle and drag it. 
 *As the rectangle is being dragged, the rectangle’s center coordinates in the text fields are updated.
 */
public class MainClass extends Application {

}

5. TestClass.java

public class TestClass {

}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.