Hey.. am in a Intro to Programming class and the following is my assignment:
1. Using the Turtle Graphics Java Package create a smile face or pumpkin face.
2. This face must have the following:
a. The head must be round. See the code below to get a circle.
b. You must use the 6 Turtle Graphics Pen Messages that can be found on the handout on my website.
c. The eyes, nose and mouth must be at least 3 sides and implemented by a loop. (repetition structure)
d. Half circle for mouth
(Hint: the for loop that only loops 3 times for each eye)
e. Draw a flow chart of your program using the correct symbols and logic.
f. Submit a copy of your source code and flowchart.
______________________________________________________________
THe following is my source code
import TurtleGraphics.*;
class face
{
public static void main(String[] args)
{
// create a pen object
SketchPadWindow pad = new SketchPadWindow(600, 600);
Pen pen = new StandardPen(pad);
// declare a variable for drawing circle
int i;
// Draw Circle for face
pen.home();
pen.setDirection(90);
pen.down();
for(i=0; i<=120; i++)
{
double side = 2.0*3.14*50.0/120.0;
pen.move(side);
pen.turn(3);
}
//draw second eye ( eye on the right )
pen.up();
pen.home();
pen.turn(90);
pen.up();
pen.move(16);
pen.down();
pen.move(20);
pen.turn(-140);
pen.move(15);
pen.turn(-90);
pen.move(12);
//draw first eye ( eye on the left )
pen.turn(-128);
pen.up();
pen.move(40);
pen.down();
pen.move(16);
pen.turn(-140);
pen.move(16);
pen.turn(-90);
The problem is that i need to loop the eyes and nose ( as requested by my teacher in point C ) so as to prevent the use of Pen commands again and again... how do i do this?
thanks much ..
1. Using the Turtle Graphics Java Package create a smile face or pumpkin face.
2. This face must have the following:
a. The head must be round. See the code below to get a circle.
b. You must use the 6 Turtle Graphics Pen Messages that can be found on the handout on my website.
c. The eyes, nose and mouth must be at least 3 sides and implemented by a loop. (repetition structure)
d. Half circle for mouth
(Hint: the for loop that only loops 3 times for each eye)
e. Draw a flow chart of your program using the correct symbols and logic.
f. Submit a copy of your source code and flowchart.
______________________________________________________________
THe following is my source code
import TurtleGraphics.*;
class face
{
public static void main(String[] args)
{
// create a pen object
SketchPadWindow pad = new SketchPadWindow(600, 600);
Pen pen = new StandardPen(pad);
// declare a variable for drawing circle
int i;
// Draw Circle for face
pen.home();
pen.setDirection(90);
pen.down();
for(i=0; i<=120; i++)
{
double side = 2.0*3.14*50.0/120.0;
pen.move(side);
pen.turn(3);
}
//draw second eye ( eye on the right )
pen.up();
pen.home();
pen.turn(90);
pen.up();
pen.move(16);
pen.down();
pen.move(20);
pen.turn(-140);
pen.move(15);
pen.turn(-90);
pen.move(12);
//draw first eye ( eye on the left )
pen.turn(-128);
pen.up();
pen.move(40);
pen.down();
pen.move(16);
pen.turn(-140);
pen.move(16);
pen.turn(-90);
The problem is that i need to loop the eyes and nose ( as requested by my teacher in point C ) so as to prevent the use of Pen commands again and again... how do i do this?
thanks much ..