So this is a java program code please do the code and please follow what in the question says and dont copy or plagarise from other sources here are some codes that require to do this question

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

So this is a java program code please do the code and please follow what in the question says and dont copy or plagarise from other sources here are some codes that require to do this question 

Rectangle java : 

public class Rectangle extends GeometricObject {
  private double width;
  private double height;

  public Rectangle() {
  }

  public Rectangle(
      double width, double height) {
    this.width = width;
    this.height = height;
  }

  public Rectangle(
      double width, double height, String color, boolean filled) {
    this.width = width;
    this.height = height;
    setColor(color);
    setFilled(filled);
  }

  /** Return width */
  public double getWidth() {
    return width;
  }

  /** Set a new width */
  public void setWidth(double width) {
    this.width = width;
  }

  /** Return height */
  public double getHeight() {
    return height;
  }

  /** Set a new height */
  public void setHeight(double height) {
    this.height = height;
  }


}

Geometric object java : 

public class GeometricObject {
  private String color = "white";
  private boolean filled;
  private java.util.Date dateCreated;

  /** Construct a default geometric object */
  public GeometricObject() {
    dateCreated = new java.util.Date();
  }

  /** Construct a geometric object with the specified color
    *  and filled value */
  public GeometricObject(String color, boolean filled) {
    dateCreated = new java.util.Date();
    this.color = color;
    this.filled = filled;
  }

  /** Return color */
  public String getColor() {
    return color;
  }

  /** Set a new color */
  public void setColor(String color) {
    this.color = color;
  }

  /** Return filled. Since filled is boolean,
     its get method is named isFilled */
  public boolean isFilled() {
    return filled;
  }

  /** Set a new filled */
  public void setFilled(boolean filled) {
    this.filled = filled;
  }

  /** Get dateCreated */
  public java.util.Date getDateCreated() {
    return dateCreated;
  }

  /** Return a string representation of this object */
  @Override
  public String toString() {
    return "created on " + dateCreated + "\ncolor: " + color +
      " and filled: " + filled;
  }
  
}

Circle java 

public class Circle extends GeometricObject {
  private double radius;

  public Circle() {
  }

  public Circle(double radius) {
    this.radius = radius;
  }

  public Circle(double radius,
      String color, boolean filled) {
    this.radius = radius;
    setColor(color);
    setFilled(filled);
  }

  /** Return radius */
  public double getRadius() {
    return radius;
  }

  /** Set a new radius */
  public void setRadius(double radius) {
    this.radius = radius;
  }

  /** Return diameter */
  public double getDiameter() {
    return 2 * radius;
  }

  /* Print the circle info */
  public void printCircle() {
    System.out.println("The circle is created " + getDateCreated() +
      " and the radius is " + radius);
  }
}

3.
\
Abstract Classes & Exception Handling
The GeometricObject, Circle and Rectangle classes are given for this question. You may
need to make necessary changes to the classes other than what is mentioned below. As a summary,
the files in your submission for this question should at least include: GeometricObject.java,
Circle. java, Rectangle. java, Triangle. java, Test TriangleWithException.java,
and TestLarger.java. Please bundle the above files and your class files in a folder named
Assignment 4Question3.
PART I:
Declare the getPerimeter () and getArea () methods in the GeometricObject class. These
two methods should be declared as abstract because they cannot be implemented in the GeometricObject
class. Override and implement getPerimeter () and getArea () in the subclasses Circle and
Rectangle. Override and implement toString() method in Circle class as:
return "Circle: radius = " + radius;
and in Rectangle class as:
return "Rectangle: width = " + width +
"
Use @Override annotation for all overridden methods.
PART II:
height =
" + height;
'
Design and implement a class named Triangle that extends GeometricObject. The class
contains:
• Three double data fields named sidel, side2, and side 3 with default values 1.0 to denote
three sides of a triangle.
• A no-arg constructor that creates a default triangle.
• A constructor that creates a triangle with the specified sidel, side2, and side 3.
• Override and implement the abstract methods getPerimeter () and getArea () in GeometricObj
class.
(Hint: The area of a triangle is given by ✓p (p - sidel) (p - side2) (p - side 3) where Ρ is
half the perimeter, that is, p =
..)
sidel+side2+side3
2
• Override and implement the toString() method as:
return "Triangle: sidel = " + sidel + "
+ ", side3 = " + side3;
Use @Override annotation for all overridden methods.
side2 = " + side2
In a triangle, the sum of any two sides is greater than the other side. The Triangle class must
adhere to this rule. Create the IllegalTriangleException class and modify the constructor
of the Triangle class to throw an IllegalTriangleException object if a triangle is created
with sides that violate the rule. The constructor of IllegalTriangleException must encap-
sulate all three sides of the triangle and a string message, as follows:
public Illegal TriangleException (double sidel, double side2,
double side3, String message)
Write a test program TestTriangleWithException to test your Triangle class and IllegalTriang
by creating two objects of Triangle with one of them violating the rule. Print the perimeter
and area of the legal triangle. Print the sides and string message of the illegal triangle from the
IllegalTriangleException caught. You may need additional methods in IllegalTriangleExcept
other than what is mentioned above. Format your output to two decimal places. A sample run is
as follows:
Legal triangle:
Perimeter: 6.50
Area: 1.33
Illegal triangle:
Sidel 1.00
Side2 2.00
Side3 3.00
The sum of any two sides is greater than the other side
Transcribed Image Text:3. \ Abstract Classes & Exception Handling The GeometricObject, Circle and Rectangle classes are given for this question. You may need to make necessary changes to the classes other than what is mentioned below. As a summary, the files in your submission for this question should at least include: GeometricObject.java, Circle. java, Rectangle. java, Triangle. java, Test TriangleWithException.java, and TestLarger.java. Please bundle the above files and your class files in a folder named Assignment 4Question3. PART I: Declare the getPerimeter () and getArea () methods in the GeometricObject class. These two methods should be declared as abstract because they cannot be implemented in the GeometricObject class. Override and implement getPerimeter () and getArea () in the subclasses Circle and Rectangle. Override and implement toString() method in Circle class as: return "Circle: radius = " + radius; and in Rectangle class as: return "Rectangle: width = " + width + " Use @Override annotation for all overridden methods. PART II: height = " + height; ' Design and implement a class named Triangle that extends GeometricObject. The class contains: • Three double data fields named sidel, side2, and side 3 with default values 1.0 to denote three sides of a triangle. • A no-arg constructor that creates a default triangle. • A constructor that creates a triangle with the specified sidel, side2, and side 3. • Override and implement the abstract methods getPerimeter () and getArea () in GeometricObj class. (Hint: The area of a triangle is given by ✓p (p - sidel) (p - side2) (p - side 3) where Ρ is half the perimeter, that is, p = ..) sidel+side2+side3 2 • Override and implement the toString() method as: return "Triangle: sidel = " + sidel + " + ", side3 = " + side3; Use @Override annotation for all overridden methods. side2 = " + side2 In a triangle, the sum of any two sides is greater than the other side. The Triangle class must adhere to this rule. Create the IllegalTriangleException class and modify the constructor of the Triangle class to throw an IllegalTriangleException object if a triangle is created with sides that violate the rule. The constructor of IllegalTriangleException must encap- sulate all three sides of the triangle and a string message, as follows: public Illegal TriangleException (double sidel, double side2, double side3, String message) Write a test program TestTriangleWithException to test your Triangle class and IllegalTriang by creating two objects of Triangle with one of them violating the rule. Print the perimeter and area of the legal triangle. Print the sides and string message of the illegal triangle from the IllegalTriangleException caught. You may need additional methods in IllegalTriangleExcept other than what is mentioned above. Format your output to two decimal places. A sample run is as follows: Legal triangle: Perimeter: 6.50 Area: 1.33 Illegal triangle: Sidel 1.00 Side2 2.00 Side3 3.00 The sum of any two sides is greater than the other side
PART III:
Implement a static method called larger that takes two geometric objects of the same type as
arguments and returns the object with larger area. If the two objects have the same area, the
method returns null. If the two geometric objects are not of the same type, the method throws
Different TypeException. DifferentTypeException is a user-defined exception. Define
it for your larger method. The method signature or larger is as follows:
static GeometricObject larger (GeometricObject gl, GeometricObject g2)
throws Different TypeException
Write a test program called Test Larger. Implement larger method in TestLarger and test
if your larger method works properly. Create different types of geometric objects to invoke the
larger method. You should test your larger method with two circles, two rectangles, two
triangles, and two different object types which should throw Different TypeException. Print
out appropriate details about the object returned by larger method such as radius, width, height,
sides, perimeter, and area. Format your output to two decimal places. A sample output is as follows:
Testing two circles of same radius:
Two objects have equal area
Testing two circles of different radius:
The returned larger object is: Circle: radius = 3.0
The area is 28.27
The perimeter is 18.85
Testing two rectangles of different sizes:
The returned larger object is: Rectangle: width = 3.0, height = 3.0
The area is 9.00
The perimeter is 12.00
Testing two triangles of different sizes:
The returned larger object is: Triangle: sidel = 2.0, side2 = 3.0, side3 = 2.3
The area is 2.30
The perimeter is 7.30
Testing two different object types:
Two objects are of different type
Please note that you are not allowed to overload larger method to accommodate Circle,
Rectangle and Triangle. You must test whether the two geometric objects are of the same
type in your larger method and throw Different TypeException in the case of different
types.
Transcribed Image Text:PART III: Implement a static method called larger that takes two geometric objects of the same type as arguments and returns the object with larger area. If the two objects have the same area, the method returns null. If the two geometric objects are not of the same type, the method throws Different TypeException. DifferentTypeException is a user-defined exception. Define it for your larger method. The method signature or larger is as follows: static GeometricObject larger (GeometricObject gl, GeometricObject g2) throws Different TypeException Write a test program called Test Larger. Implement larger method in TestLarger and test if your larger method works properly. Create different types of geometric objects to invoke the larger method. You should test your larger method with two circles, two rectangles, two triangles, and two different object types which should throw Different TypeException. Print out appropriate details about the object returned by larger method such as radius, width, height, sides, perimeter, and area. Format your output to two decimal places. A sample output is as follows: Testing two circles of same radius: Two objects have equal area Testing two circles of different radius: The returned larger object is: Circle: radius = 3.0 The area is 28.27 The perimeter is 18.85 Testing two rectangles of different sizes: The returned larger object is: Rectangle: width = 3.0, height = 3.0 The area is 9.00 The perimeter is 12.00 Testing two triangles of different sizes: The returned larger object is: Triangle: sidel = 2.0, side2 = 3.0, side3 = 2.3 The area is 2.30 The perimeter is 7.30 Testing two different object types: Two objects are of different type Please note that you are not allowed to overload larger method to accommodate Circle, Rectangle and Triangle. You must test whether the two geometric objects are of the same type in your larger method and throw Different TypeException in the case of different types.
Expert Solution
steps

Step by step

Solved in 5 steps with 10 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education