I've drawn two trees in
Java that stand next to each other that are the same color and height. But I'm trying to code three sets of trees with different widths and get those three sets of trees to generate randomly when I run the code. The way I've coded it makes each triangle change widths at random, but I want the whole tree to be one of three sizes everytime I run and compile. What am I doing wrong?
Scanner console = new Scanner(System.in);
int width = 50* (int)(Math.random()*3+1);
int width2 = 50* (int)(Math.random()*3+1);
int width3 = 50* (int)(Math.random()*3+1);
int width4 = 50* (int)(Math.random()*3+1);
int width5 = 50* (int)(Math.random()*3+1);
int width6 = 50* (int)(Math.random()*3+1);
int height = 50;
Triangle triangle1;
Triangle triangle2;
Triangle triangle3;
Square trunk1;
Square trunk2;
Triangle triangle4;
Triangle triangle5;
Triangle triangle6;
Square trunk3;
Square trunk4;
triangle1 = new Triangle();
triangle1.changeSize(50,140);
triangle1.moveHorizontal(25);
triangle1.moveVertical(70);
triangle1.makeVisible();
triangle2 = new Triangle();
triangle2.changeSize(50,140);
triangle2.moveHorizontal(25);
triangle2.moveVertical(120);
triangle2.makeVisible();
triangle3 = new Triangle();
triangle3.changeSize(50,140);
triangle3.moveHorizontal(25);
triangle3.moveVertical(170);
triangle3.makeVisible();
trunk1 = new Square();
trunk1.changeColor("black");
trunk1.moveVertical(185);
trunk1.makeVisible();
trunk2 = new Square();
trunk2.changeColor("black");
trunk2.moveVertical(200);
trunk2.makeVisible();
triangle4 = new Triangle();
triangle4.changeSize(50,140);
triangle4.moveHorizontal(150);
triangle4.moveVertical(70);
triangle4.makeVisible();
triangle5 = new Triangle();
triangle5.changeSize(50,140);
triangle5.moveHorizontal(150);
triangle5.moveVertical(120);
triangle5.makeVisible();
triangle6 = new Triangle();
triangle6.changeSize(50,140);
triangle6.moveHorizontal(150);
triangle6.moveVertical(170);
triangle6.makeVisible();
trunk3 = new Square();
trunk3.changeColor("black");
trunk3.moveHorizontal(125);
trunk3.moveVertical(185);
trunk3.makeVisible();
trunk4 = new Square();
trunk4.changeColor("black");
trunk4.moveHorizontal(125);
trunk4.moveVertical(200);
trunk4.makeVisible();
System.out.println ("Hello, Welcome to terminal.\n");
System.out.println ("This program will draw two trees next to each other where the widths");
System.out.println ("of the triangles on the trees randomly vary between 50,100, and 150");
}
}