Chris Pollett>Old Classes>PIC 20, Winter 2000>Hw2
>java Pattern 7 55 7 9 2 Sorry, doesn't contain the pattern. >java Pattern 5 4 -79 8 7 7 7 9 0 3 Yes, that has the pattern. >java Pattern 0 7 7 9 0 0 0 Yes, that has the pattern.You can assume like above that all arguments will be integers. The grader will test on these as well as two other sets of inputs. You should use a break to get out of your loop once you have accepted an input. You should also use a switch/case structure somewhere in your program. To do this assignment it helps to come up with a finite state diagram (will mention in class) which accepts the above kinds of strings and then implement that in java.
void drawTri(int xPts[], int yPts[], Graphics g, int nest)
which is called by the paint method after a button click and a nesting
depth has been entered. If nest >=1
,
this method calls g.drawPolygon(xPts, yPts,3);
to print a triangle. Then by finding the midpoints of each edge in this
triangle it makes three new triangles and calls drawTri on these
three new three new triangles but on a one smaller value of
nest.
Self-similarity just means that if you could continue the nesting
of triangles to infinity that each subtriangle would look like a copy of
the whole triangle. The coordinates of your outermost triangle only
need to be roughly the same as mine.