public class OldMain {
public static void main (String[] argv) {
new OldMain();
}
OldMain() {
type_ = new int[NUMSHAPES];
name_ = new String[NUMSHAPES];
radius_ = new int[NUMSHAPES];
height_ = new int[NUMSHAPES];
width_ = new int[NUMSHAPES];
makeShapes();
printShapes();
}
void makeShapes() {
for (int i=0; i<name_.length; i++) {
type_[i] = (int)(Math.random() * NUMTYPES);
switch (type_[i]) {
case CIRCLE:
name_[i] = "Circle " + numCircles__++;
makeCircle(i);
break;
case RECTANGLE:
name_[i] = "Rectangle " + numRectangles__++;
makeRectangle(i);
break;
}
}
}
void printShapes() {
for (int i=0; i<name_.length; i++) {
System.out.print(name_[i] + " [");
switch (type_[i]) {
case CIRCLE:
printCircle(i);
break;
case RECTANGLE:
printRectangle(i);
break;
}
System.out.println("]");
}
}
void makeCircle(int i) {
radius_[i] = (int)(Math.random() * MAXRADIUS);
}
void makeRectangle(int i) {
height_[i] = (int)(Math.random() * MAXHEIGHT);
width_[i] = (int)(Math.random() * MAXWIDTH);
}
void printCircle(int i) {
System.out.print("radius: " + radius_[i]);
}
void printRectangle(int i) {
System.out.print("height: " + height_[i]);
System.out.print("; ");
System.out.print("width: " + width_[i]);
}
static final int NUMTYPES = 2;
static final int CIRCLE = 0;
static final int RECTANGLE = 1;
static final int MAXRADIUS = 70;
static final int MAXWIDTH = 50;
static final int MAXHEIGHT = 110;
static final int NUMSHAPES = 10;
static int numCircles__ = 0;
static int numRectangles__ = 0;
int type_[];
String name_[];
int radius_[];
int height_[];
int width_[];
}