The following code is provided for the second programming exam of Spring 2015.
You may copy this main() method into your code. Remember, additional testing is strongly recommended but not required.
public static void main(String[] args) {
StdDraw.setXscale(-1, 1);
StdDraw.setYscale(-1, 1);
Color r = StdDraw.RED;
Diamond d = new Diamond(.5, 0, 0, r);
d.drawFilled();
System.out.println(d.area());
d.changeColor(StdDraw.LIGHT_GRAY);
d.move(.5, -.5);
d.drawFilled();
System.out.println(d.area());
}
You may copy this main() method into your code. Remember, additional testing is strongly recommended but not required.
public static void main(String[] args) {
StdDraw.setXscale(-1, 1);
StdDraw.setYscale(-1, 1);
Color g = StdDraw.LIGHT_GRAY;
Ngon d1 = new Ngon(4, .35, .5, -.5, g);
System.out.println(d1.area());
Ngon d2 = new Ngon(4, .35);
Ngon m = d1.merge(d2);
m.drawFilled();
d1.drawFilled();
d2.drawFilled();
Ngon pent = new Ngon(5, .25, 0, 0, g);
pent.drawFilled();
}
Use the following sample input files to test your code.