help with an assignment programming (java)

User Generated

Nobbq27k

Computer Science

Description

do everything in the instructions file.

Note: the code of (Circle, ConvexPolygon, Point, Shape) files have done, there are other four files have to solve.

However, I could not attach the java files here! let me know how I can sent it to you.

Unformatted Attachment Preview

Deadline: November 26 23:59 The goals of this lab are: ● implement classes from specifications, ● write and use unit testing to verify your solution, and ● implement a GUI. Introduction In lab 09 you implemented an hierarchy of classes to represent 2D shape objects. Now it is time to build an application that allows the visualization of shape objects. For your reference the classes created in lab 09 are summarized by the UML class diagram below. UML Class Diagram This lab is divided in two parts to help your implementation. Part I In Part I you are asked to build an application that uses the hierarchy of classes from lab 09 that demonstrates the use of 2D shape objects and that follows the minimum requirements specified below: ● the application must implement a GUI to show up to n randomly generated shape objects, with n easily changed; ● when generating the shapes, the application should be able to switch between different types of shapes, alternating between circle and polygon shapes; ● when the application reaches the n shape objects generated it should then automatically remove the oldest shape on the next iteration; ● the application should “run forever” until the user closes the GUI’s frame; ● when the application generates a circle, the center and the radius of the circle should be randomly assigned; ● when the application generates a polygon, the number of sides and the location of the vertices should be randomly assigned; ● of course the higher the number of vertices the lower is the probability of finding a polygon that is convex; therefore, to avoid having long waits (while the application is trying to generate a convex polygons) the application should automatically decrease the number of vertices whenever it fails to instantiate a convex polygon until it reaches the minimum value of three vertices; ● all shapes generated should also have a minimum area of 104 and a maximum area of 102 0 . Part of the code to generate the GUI is given to you and it is very similar to the code you used in the first programming assignment. You are not required to use the provided code. However the application should be run by the ShapesDemo class and make use of the hierarchy of class developed in lab 09. Part II In this part of the assignment you will add some “spice” to your shapes demo application. The polygon shapes should have the ability to rotate over their centers given a certain angle in degrees. Search online how to rotate polygons and add this new feature to your polygon shapes. Part II In this part of the assignment you will add some “spice” to your shapes demo application. The polygon shapes should have the ability to rotate over their centers given a certain angle in degrees. Search online how to rotate polygons and add this new feature to your polygon shapes. Rubric (Grading) +75 Part I +20 circle shapes randomly generated. +25 polygon shapes randomly generated. +5 polygon shapes generation automatically decreases number of vertices down to 3 when fails to generate convex polygon . +10 application maintains a list of n shapes and automatically removes oldest shape. +5 shapes have area between configurable limits. +10 GUI similar to expectations. +25 Part II +5 method to compute the center of a polygon. +10 method to rotate a polygon over its center given an angle in degrees. +10 GUI shows rotation.
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

Just keeping all files in one place:Feel free to ask any doubts you have, or bugs you encounter...

package guiGen;
import
import
import
import
import

java.awt.Color;
java.awt.Graphics;
java.util.ArrayList;
javax.swing.JPanel;
java.awt.Polygon;

class ShapesPanel extends JPanel {
private ShapesGUI gui;
ShapesPanel(final ShapesGUI gui) {
this.gui = gui;
}
@Override
public void paintComponent(Graphics g) {
g.setColor(Color.BLACK);
// TODO: change the implementation
//All Shapes
ArrayList shapes = this.gui.getShapes();
for (Shape shape : shapes) {
if (shape instanceof Circle) {
// draw a circle
Circle circle = (Circle) shape;
Point center = circle.getCenter();
int radius = (int) circle.getRadius();
int guiX = (int) (center.getX());
int guiY = (int) (center.getY());
g.fillOval(guiX, guiY, 4, 4);
g.drawOval(guiX - radius / 2, guiY - radius / 2, radius,
radius);
} else {
// draw a polygon===============================
ConvexPolygon cp = (ConvexPolygon) shape;
//Rotating 10 deg, every time the polygon is used
cp.rotate();
Point center = cp.getCenter();
int guiX = (int) (center.g...


Anonymous
Nice! Really impressed with the quality.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Similar Content

Related Tags