Question: Hello! Please complete the following using Java you will be using fxraphicsTemplate for assistance and define multiple classes for objects that can draw themselves on
Hello! Please complete the following using Java
you will be using fxraphicsTemplate for assistance and define multiple classes for objects that can draw themselves on a GraphicsContext. All the objects will be related to one another through the relationship of association. Then you will create a simple graphical app to display the objects.
Description:
The turtle ro bots consist of three nests and a single adult female turtlethese three objects are the model. The view for this assignment is a class created using the fxGraphicstemplate which creates and draws the model. A nest has a location name and contains baby turtles of the same colour, each with a random number integer represeting their weight. A turtle has a head and a tail when drawn.
The UML class diagram below shows which classes you are to develop and how they relate to one another. Make sure you implement the UML class diagrams exactly as shown. The bale of turtles should not always look the same on every run. Please make it so the weight and colour are determined randomly.
Below are notes on each of the classes in the UML class diagram to assist you.
HEAD
A Head is an oval, rectangle, or other headlike shape with a neck shape attached. Its x and y location determine its top left corner and the neck is drawn relative to that.
TAIL
A tail is a rectangle, oval, or other tail like shapes. Its x and y locations determine its top left corner.
TURTLE
A Turtle is a body shape with its weight displayed within itunless it is a female turtle. The turtles SHOULD NOT look like the picture make them unique. A Turtles x and y location determine the top left corner of its body shape, and it contains a Head and a Tail, appropriately sized, somewhere within or around its body. The first constructor creates a baby turtle with a random weight passed inThe second constructor is used to create the female turtle with a weight set to Turtle constructors create Head and Tail objects with placement based on the Turtles own location. The draw method draws the body and Turtle, then calls the Head and Tail draw methods.
NEST
A Nest has three Turtles of the same color. The Turtles in a Nest are drawn in a straight line from left to right, spaced out nicely. The location of a Nest corresponds to the location its first Turtle. The Nest constructor creates the Turtles. When a Nest draws itself, it calls the Turtle draw methods, then it draws text underneath with the name of the Nest and its average weight of the Turtles in the nest.
BEACH
Beach Finally, you should create a Beach class not shown in the diagramto serve as the view for the model described above. This class will be based on fxGraphicsTemplate. It should create three Nests and a female Turtle from one of the nests selected randomlyand draw them. If done correctly, this should only take a few lines of code to create and draw each object
fxgraphicstemplate:
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.stage.Stage;
import static javafx.application.Application.launch;
Use this template to create drawings in FX Change the name of the class and
put your own name as author below. Change the size of the canvas and the
window title where marked and add your drawing code where marked.
@author YOUR NAME
public class FXGraphicsTemplate extends Application
Start method use this instead of main
@param stage The FX stage to draw on
@throws Exception
@Override
public void startStage stage throws Exception
Group root new Group;
Scene scene new Sceneroot;
Canvas canvas new Canvas; Set canvas Size in Pixels
stagesetTitleFXGraphicsTemplate; Set window title
rootgetChildrenaddcanvas;
stagesetScenescene;
GraphicsContext gc canvas.getGraphicsContextD;
YOUR CODE STARTS HERE
YOUR CODE STOPS HERE
stageshow;
The actual main method that launches the app.
@param args unused
public static void mainString args
launchargs;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
