I need to insert some comments on this TwoD method, but I am not sure if this is the correct comment for this method as TwoD is the reference Type:
// generate a random integer from 1 to 10
private static int getInt() {
return (int) (Math.random() * 10) + 1;
}
// generate random object of TwoD reference type
private static TwoD getTwoD() {
// generate a random integer from 0 to 2
int randomInt = (int)(Math.random() * 3);
TwoD twoD;
switch(randomInt) {
case 0:
twoD = new Circle(getInt());
break;
case 1:
twoD = new Rectangle(getInt(), getInt());
break;
default:
twoD = new Triangle(getInt(), getInt(), getInt());
}
}