Question
Triangle Project (JAVA) Create a New Java Project called YourLastNameInheritance . Design a class named Triangle that extends the GeometricObject class. The UML diagram for
Triangle Project (JAVA)
Create a New Java Project called YourLastNameInheritance.
Design a class named Triangle that extends the GeometricObject class. The UML diagram for the GeometricObject class is provided below.
The Triangle class contains:
Three double data fields named side1, side2, and side3 with default values 1.0 to denote three sides of the triangle.
A no-arg constructor that creates a default triangle.
A constructor that creates a triangle with the specified side1, side2, and side3.
The accessor methods for all three data fields.
A method named getArea() that returns the area of this triangle.
A method named getPerimeter() that returns the perimeter of this triangle.
A method named toString() that returns a string description for the triangle. The toString() method is implemented as follows:
return "Triangle: side` = " + side1 + " side2 = " + side2 + " side3 = " + side3;
Once you have written the classes, use it in an application that creates a Triangle object and asks the user to enter the values of the sides, the triangle's color, and whether or not it is filled. Then display the lengths of each side, along with the area, perimeter, color, and whether filled or not.
Input Validation: Do not accept unreasonable/junk values, or negative values, which must be rejected and asked for another one.
NOTE: Each class should be defined in its own class file.
Please provide a sample of the input and output of the working program.
PROGRAMMING GUIDELINES: A programming assignment will be assigned a grade of 0 if it fails to compile. Each program must not contain any spelling errors in the program output or points will be deducted. Each program must contain a comment section (or points will be deducted) that indicates the following: 1. Student Name 2. Program Name 3. Short Program Description 4. Due Date Programs should use appropriate spacing and indentation, in order to increase readability. Programs should only be completed in Eclipse. Use comments for clarification throughout your programs. Use meaningful variable names. Subdivide your program into mini-sections. For more difficult programs, this will make it easier to detect both syntax and logical errors. Naming Convention for mutator methods: set + fieldname (i.e. setName) Naming Convention for accessor methods: get + fieldname (i.e. getName)
GeometricObject -color : String -filled : Boolean -dateCreated : java.util.Date +GeometricObject() +getColor() : String +setColor(color : String) : void +isFilled() : Boolean +setFilled(filled : Boolean) : void +getDateCreated() : java.util.Date +toString() : String GeometricObject -color : String -filled : Boolean -dateCreated : java.util.Date +GeometricObject() +getColor() : String +setColor(color : String) : void +isFilled() : Boolean +setFilled(filled : Boolean) : void +getDateCreated() : java.util.Date +toString() : StringStep 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