我需要在这个 TwoD 方法上插入一些注释,但我不确定这是否是这个方法的正确注释,因为 TwoD 是参考类型:// generate a random integer from 1 to 10private static int getInt() { return (int) (Math.random() * 10) + 1;}// generate random object of TwoD reference typeprivate 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()); }}
添加回答
举报
0/150
提交
取消