How to create my peasant:
To begin with, to create the peasant picture, you must have all the classes necessary to complete the body parts. The box class, which I will cover how to create further into the procedure, the triangle class, and the circle class, are all necessary classes to have before creating specific multiple instances to create the picture. To create the box class, I followed the steps given to us, in which I essentially copied the code, including the methods, constructors, and fields, of the square class, and simply changed the size field into two fields, width and height. I also had to change the overall name of the class in the code into box, and also the square words into box from the signatures of the square code. Since the triangle and circle classes are given, there was no reason to change anything within them. I then moved on to the picture class, where I would make the specific instances of each class that were needed in the picture. I needed one box for the body, two boxes for the arms, two boxes for the legs, a circle for the head, and a triangle for his hat. All the objects in the picture had different and specific parameters which were found through a basic knowledge of mathematics and graphing, as well as a lot of guess-and-check. For the purpose of creating my exact peasant, I will include a code for each of my objects and cover what each field means:
hat = new Triangle();
hat.changeColor("black");
hat.moveHorizontal(87);
hat.changeSize(50, 60);
hat.makeVisible();
head = new Circle();
head.moveVertical(2);
head.moveHorizontal(93)
head.changeSize(50);
head.makeVisible();
body = new Box();
body.changeColor("black");
body.moveHorizontal(120);
body.moveVertical(110);
body.changeHeight(40);
body.changeWidth(80);
body.makeVisible();
arm1 = new Box();
arm1.changeColor("black");
arm1.moveHorizontal(90);
arm1.moveVertical(110);
arm1.changeHeight(35);
arm1.changeWidth(10);
arm1.makeVisible();
arm1 = new Box();
arm1.changeColor("black");
arm1.moveHorizontal(155);
arm1.moveVertical(110);
arm1.changeHeight(35);
arm1.changeWidth(10);
arm1.makeVisible();
leg1 = new Box();
leg1.changeColor("black");
leg1.moveHorizontal(120)
leg1.moveVertical(190);
leg1.changeHeight(10);
leg1.changeWidth(35);
leg1.makeVisible();
leg2 = new Box();
leg2.moveHorizontal(150);
leg2.moveVertical(190);
leg2.changeHeight(10);
leg2.changeWidth(35);
leg2.makeVisible();
No comments:
Post a Comment