Question
Do in java please This was the code provided: class Point{ //Reuse the code of Method Overloading - Exercise 1 //Uncomment the below method after
Do in java please
This was the code provided:
class Point{ //Reuse the code of Method Overloading - Exercise 1 //Uncomment the below method after implementation before verifying //DO NOT MODIFY THE METHOD /* public String toString(){ return "Point xCoordinate: "+this.getxCoordinate()+" yCoordinate: "+this.getyCoordinate(); } */ }
class Triangle { //Implement your code here }
class Tester {
public static void main(String[] args) { Triangle triangle1 = new Triangle(); Triangle triangle2 = new Triangle(1, 2, 6, 5, 5, 1); Point point1 = new Point(2, 1); Point point2 = new Point(4, 4); Point point3 = new Point(9, 1); Triangle triangle3 = new Triangle(point1, point2, point3); System.out.println("Perimeter of triangle1 is "+triangle1.calculatePerimeter()); System.out.println("Area of triangle1 is "+triangle1.calculateArea()); System.out.println("Perimeter of triangle2 is "+triangle2.calculatePerimeter()); System.out.println("Area of triangle2 is "+triangle2.calculateArea()); System.out.println("Perimeter of triangle3 is "+triangle3.calculatePerimeter()); System.out.println("Area of triangle3 is "+triangle3.calculateArea()); //Create more objects of Triangle class for testing your code
} }
The Triangle class is used for representing triangles. The vertices of the triangle will be represented using the Point class created in Method Overloading - Exercise 1. Implement the class Triangle based on the class diagram and description given below. Triangle point1: Point u point2: Point point3: Point Triangle Triangle(point1xCoordinate: double, point1yCoordinate double point2xCoordinate: double, point2yCoordinate double, point3xCoordinate double point 3CooL Trangle(point Point point Point pointa Point calculate Perimeter: double calculate Area(): double .getPoint 10 Point setPoint(pointi: Point) void getPoint. Point setPointpoint Point) void getPoint Point Pointpoint Point void Method Description Triangle Initialize the instance variables pointi, point and point with the following coordinate values pointi - 0,0 point2 - 1,1 .Step 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