Implement all the classes using Java programming language from the given UML Class diagram. Note: This problem requires you to submit just two classes: MyTriangle.java, MyPoint.java.

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

Implement all the classes using Java programming language from the given UML Class diagram.

Note: This problem requires you to submit just two classes: MyTriangle.java, MyPoint.java.

Do NOT include "public static void main()" method inside all of these classes. The classes would be tested, using the unit-testing framework JUnit 4.

A class called MyTriangle, which models a triangle with 3 vertices, is designed as shown. The MyTriangle class uses three MyPoint instances (created in the earlier exercise) as its three vertices.

It contains:

  • Three private instance variables v1, v2, v3 (instances of MyPoint), for the three vertices.
  • A constructor that constructs a MyTriangle with three sets of coordinates, v1=(x1, y1), v2=(x2, y2), v3=(x3, y3).
  • An overloaded constructor that constructs a MyTriangle given three instances of MyPoint.
  • A toString() method that returns a string description of the instance in the format "MyTriangle[v1=(x1,y1),v2=(x2,y2),v3=(x3,y3)]".
  • A getPerimeter() method that returns the length of the perimeter in double. You should use the distance() method of MyPoint to compute the perimeter.
  • A method printType(), which prints "equilateral" if all the three sides are equal, "isosceles" if any two of the three sides are equal, or "scalene" if the three sides are different.

Write the MyTriangle and MyPoint classes and submit as your solution.

MyTriangle
МуРoint
3
-v1:MyPoint
-v2:MyPoint
-v3:MyPoint
-x:int
vertices -y:int
+MyTriangle(x1:int,y1:int,
x2:int,y2:int,x3:int,
у3:int)
+MyTriangle(v1:MyPoint,
v2:MyPoint, v3: MyPoińt)
+toString():String •
+getPerimeter():double.
+getType ():String
"MyTriangle[v1=(x1,y1),v2=(x2,y2),v3=(x3,y3)]"
Use MyPoint's distance() to compute
the length of the edges.
"Equilateral" or "Isosceles" or "Scalene"
Transcribed Image Text:MyTriangle МуРoint 3 -v1:MyPoint -v2:MyPoint -v3:MyPoint -x:int vertices -y:int +MyTriangle(x1:int,y1:int, x2:int,y2:int,x3:int, у3:int) +MyTriangle(v1:MyPoint, v2:MyPoint, v3: MyPoińt) +toString():String • +getPerimeter():double. +getType ():String "MyTriangle[v1=(x1,y1),v2=(x2,y2),v3=(x3,y3)]" Use MyPoint's distance() to compute the length of the edges. "Equilateral" or "Isosceles" or "Scalene"
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Class
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
  • SEE MORE 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