Java A point is inside the triangle. (b) A triangle is inside another triangle.
ID: 3785128 • Letter: J
Question
Java
A point is inside the triangle. (b) A triangle is inside another triangle. (c) A triangle overlaps another triangle. Draw the UML diagram for the class and then implement the class. Write a test program that creates a Triangle2D objects t1 using the constructor new Triangle2D(new MyPoint(2, 5, 2), new MyPoint(4, 2, 3), new MyPoint(5, 3, 5)), displays its area and perimeter, and displays the result of t1.contains(3, 3), r1.contains(new Triangle2D(new MyPoint(2, 9, 2), new MyPoint(4, 1), MyPoint(1. 3.4))), and t1, overlaps(new Triangle2D(new MyPoint(2, 5, 5), new MyPoint(4, -3), MyPoint(2, 6, 5))).Explanation / Answer
public class Mypoint()
{
private float x;
private int y;
public Mypoint(float x, int y)
{
this.x =x;
this.y =y;
}
}
public class Triangle2D{
private Mypoint x;
private Mypoint y;
private Mypoint z;
public Triangle2D(Mypoint a,Mypoint b,Mypoint c)
{
this.x = a;
this.y = b;
this.z = c;
}
public static void main(String []args){
Mypoint a = new Mypoint(2.5,2);
Mypoint b = new Mypoint(4.2,3);
Mypoint c = new Mypoint(5,3.5);
Triangle2D t1 =new Triangle2D(a,b,c);
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.