0

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());
    }


}
Mireodon
  • 165
  • 1
  • 11

1 Answers1

0

You're not creating random objects, you're creating random instances.

Read the following question for further information and then write your comments accordingly.

The difference between Classes, Objects, and Instances

Emre Acar
  • 920
  • 9
  • 24