Transcript Lecture23

 Project 3 discussion
Project 3 - Output
6/30/2016
CS110-Spring 2005, Lecture 8
2
Project 3 - Pseudo code
• Paint method:
– Start method ( Put { )
– Declare variables x1, y1, x2, y2, x3, y3 of type double and
initialize them so that they make equilateral triangle. (x1, y1)
will make point p1, (x2, y2) will make point p2 and (x3, y3) will
make point p3.
– Set canvas color to be red
– Draw line from (x1,y1) to (x1,y1). You need to use casting
here.
• drawLine((int)x1,(int)x2,(int)x1,(int)x2);
–
–
–
–
–
Set canvas color to be blue
Draw line from (x2,y2) to (x2,y2). Use casting.
Set canvas color to be green
Draw line from (x3,y3) to (x3,y3). Use casting.
Declare variables currentX and currentY of type double and
initialize them to x1 and y1 respectively.
– Create an instance of Die class
6/30/2016
CS110-Spring 2005, Lecture 8
3
Project 3 (Contd.)
– For each value of I from 1 to 100000.
• Start loop
• Roll the die
• Use some conditional statement and check if value of die is 1
then
–
–
–
–
–
Start conditional
Set currentX = (currentX + x1)/2
Set currentY = (currentY + y1)/2
Set canvas color to be red.
End conditional
• Repeat the previous step for die value 2 and die value 3
accordingly.
• Draw line from (currentX,currentY) to (currentX,currentY).
You need to use casting here.
• End loop
– End method (Put } )
6/30/2016
CS110-Spring 2005, Lecture 8
4