Your interface
is not valid. Indeed, you have two methods called getLocation()
that return different objects. Maybe you will have to choose different names, such as:
Point getLocationAsPoint();
Dimension getLocationAsDimension();
Now, if you use Eclipse, you can simply create a new class, indicate that this class implements the Triangle
interface, and it will create the following skeleton:
public class MyTriangle implements Triangle {
@Override
public List<Point> getApexes() {
// TODO Auto-generated method stub
return null;
}
@Override
public void moveApex(Point from, Point to) {
// TODO Auto-generated method stub
}
@Override
public void rotate(double angle) {
// TODO Auto-generated method stub
}
@Override
public void setLocation(Point p) {
// TODO Auto-generated method stub
}
@Override
public void setSize(Dimension d) {
// TODO Auto-generated method stub
}
@Override
public Dimension getLocationAsDimension() {
// TODO Auto-generated method stub
return null;
}
@Override
public Point getLocationAsPoint() {
// TODO Auto-generated method stub
return null;
}
}
Then, simply write the code for each method. I strongly recommend you to go for TDD in order to complete your task correctly.
Eclipse can create a new JUnit test class that will be your starting point: Create a new JUnit Test Case, and select MyTriangle
in the Class under test option in the class creation wizard.