Basically i need to build this MyTriangle class. together with the code from MyPoint, i need to test out the following.
oop.jpg
when i try to build the constructor part where v1 = (x1, y1) it says my y1 is not a int variable.
also how do i link the two class together?
MyPoint code is as followed:
public class MyPoint { private int x; private int y; public MyPoint(){ x = 0; y = 0; }public MyPoint(int x, int y){ this.x = x; this.y = y; }public int getX(){ return x; }public void setX(int x){ this.x = x; }public int getY(){ return y; }public void setY(int y){ this.y = y; }public void setXY(int x, int y){ this.x = x; this.y = y; }public String toString(){ return "(" + x + ", " + y + ")"; }public double distance(int x, int y){ int xDiff = this.x - x; int yDiff = this.y - y; return Math.sqrt(xDiff*xDiff + yDiff*yDiff); }public double distance(MyPoint another){ int xDiff = this.x - another.x; int yDiff = this.y - another.y; return Math.sqrt(xDiff*xDiff + yDiff*yDiff); } }