Question
Problem: shapes The aim is to start the development of an application to plot shapes in a canvas. Each shape is identified by a unique
Problem: shapes The aim is to start the development of an application to plot shapes in a canvas. Each shape is identified by a unique integer value, named identifier. It should be possible to add, remove and get shapes (a single shape when specifying an identifier or all the shapes otherwise, as a array of shapes). It must be possible to print the characteristics of each shape. A shape can be either a disk or a rectangle defined by points. It should be possible to declare a shape as filled or not. A disk can be constructed using a central point and a radius, or using 2 points defining its diameter. A rectangle can be constructed using 2 points defining one of its diagonal, or using one point, a width and a height. The 3 following services should be provided: 1. draw the shapes 2. check whether a point is inside at least one filled shape in a canvas 2. compute the surface of the filled shapes of a canvas Guidelines Make classes Disk, Rectangle and Square Make abstract class Shape that are able to Calculate the perimeter and surfaces Plot Look on internet for Java class Graphics and JFrame On javadoc On tutorials Make a main class that plots the rectangles and disks If finished, make the Polygon class (and Point class) Clues to draw frame
public Testo super ("My frame") setPreferredSize (new Dimension (500, 500)); setDefaultcloseOperation (JFrame. EXIT_ON CLOSE) setVisible (true) pack) public void paint (Graphics g) super.paint (g) g.setcolor (Color. BLUE): g.drawRe et (100, 100, 60, 100)- public Testo super ("My frame") setPreferredSize (new Dimension (500, 500)); setDefaultcloseOperation (JFrame. EXIT_ON CLOSE) setVisible (true) pack) public void paint (Graphics g) super.paint (g) g.setcolor (Color. BLUE): g.drawRe et (100, 100, 60, 100)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started