Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a java swing project. The requirements are that the four classes are part of a package with final core class containing the main

This is a java swing project. The requirements are that the four classes are part of a package with final core class containing the main

public class Project3 {

abstract class Shape extends Rectangle{

see below

}

class Rectangular extends Shape {

}

class Oval extends Shape {

}

class Drawing extends JPanel {

}

class ProjectCore extends JPanel {

public static void main(String[] args) {

}

}

)

looking for help for the rest.

image text in transcribed

The Shape class has two subclasses: Oval and Rectangular.

The first subclass is Oval. It should have the following two methods:

  1. A constructor that accepts three parameters for the purpose of initializing the characteristics of the shape, a Rectangle object that defines
    1. Dimensions and position of the shape
    2. Color of the shape
    3. Shape is solid or hollow.
  2. An overridden method draw that draws the Oval object on the Graphics object passed as a parameter.

The second subclass is Rectangular. It should have the following two methods:

  1. A constructor that accepts three parameters for the purpose of initializing the characteristics of the shape, a Rectangle object that defines
    1. Dimensions and position of the shape
    2. Color of the shape
    3. Shape is solid or hollow.
  2. An overridden method draw that draws the Rectangular object on the Graphics object passed as a parameter.

The fourth class is named Drawing, which should extend the predefined Java class JPanel. It has one instance variable that contains the shape that is currently drawn. It should have three methods:

  1. An overridden paintComponent method that draws the current shape on the Graphics object that is passed to it as a parameter. It should also draw the number of shapes that have been created thus far in the upper left corner.
  2. An overridden getPreferredSize method that specifies the dimensions of the drawing panel as 200 pixels wide and 200 pixels high.
  3. An instance method named drawShape that is passed the current shape to be drawn. It first checks whether the shape provided will completely fit within the panel. If not, it throws an OutsideBounds exception. Otherwise, it saves the shape in the corresponding instance variable. It then calls repaint to cause that shape to be drawn.

image text in transcribed

The combo-box for the Shape Type should allow two choices, either Rectangle or Oval. The combo-box for the Fill Type should also allow two choices, either Hollow or Solid. The combo-box for the Color should allow seven choices, Black, Red, Orange, Yellow, Green, Blue or Magenta.

Clicking the Draw button should first check whether any non-integer values have been entered in any of the fields that require integers. If so, an error message should be displayed in a JOptionPane window. Otherwise an appropriate Shape object should be created and passed to the drawShape method of the Drawing class. If that call results in an OutsideBounds exception being thrown, an appropriate error message should be displayed in a JOptionPane window.

Be sure to follow good programming style, which means making all instance variables private, naming all constants and avoiding the duplication of code. Furthermore, you must select enough different kinds of shapes for a comprehensive Test Plan for the program.

abstract class Shape extends Rectangle{ String color, shape_solid_hollow; int no_of_shape=0; Shape (Rectangle r, string color, string shape_solid_hollow) { no_of_shape++; this.color=color; this.shape_solid_hollow=shape solid hollow; void setColor (Graphics g) { if (color.equals("green")) g.setColor (Color.green); else if (color.equals("red")) g.setColor (Color.red); string getsolid() { return shape_solid hollow; int getNoofShapes () { return no_of_shape; abstract void draw (Graphics g); No additional public methods should be included in any of the above classes. The fifth class named OutsideBounds should define a checked exception. The Program Core should contain the main method. It should generate the GUI shown below: 1 Geometric Drawing - O X Shape Drawing T Shape Draw Shape Type Oval Fill Type Solid Color Red Width 100 Height 125 An x coordinate y coordinate Draw abstract class Shape extends Rectangle{ String color, shape_solid_hollow; int no_of_shape=0; Shape (Rectangle r, string color, string shape_solid_hollow) { no_of_shape++; this.color=color; this.shape_solid_hollow=shape solid hollow; void setColor (Graphics g) { if (color.equals("green")) g.setColor (Color.green); else if (color.equals("red")) g.setColor (Color.red); string getsolid() { return shape_solid hollow; int getNoofShapes () { return no_of_shape; abstract void draw (Graphics g); No additional public methods should be included in any of the above classes. The fifth class named OutsideBounds should define a checked exception. The Program Core should contain the main method. It should generate the GUI shown below: 1 Geometric Drawing - O X Shape Drawing T Shape Draw Shape Type Oval Fill Type Solid Color Red Width 100 Height 125 An x coordinate y coordinate Draw

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What are the objectives of Human resource planning ?

Answered: 1 week ago

Question

Explain the process of Human Resource Planning.

Answered: 1 week ago