In this assignment, you will work a modified version of problem 6.16 on page 377 of your text. The problem asks you to use the fillPolygon() method in the Graphics class to draw 10 randomly sized and located stars. To make the job more fun, you will be given a class called PolyStar that can be used to calculate the coordinates needed to specify a star. Using PolyStar, you can not only vary the size and location of a star, but you can also create stars with different numbers of points. Below is a display of four stars created with the help of the methods in the PolyStar class.
Your assignment is to write an applet named Star that creates 5 or more stars with the following characteristics:
The PolyStar class is provided on this link. When a PolyStar object is created, the following information must be specified:
Once a PolyStar object has been created, the methods getOuterPoint() and getInnerPoint() can be used to determine the x and y coordinates that are input to fillPolygon() when drawing the star. Each method takes a point number representing a point on the star and returns a Point object containing the x,y coordinate of that point. The point numbers for a 5-point star are shown below.
Point numbers always begin with zero. They correspond to points of
slope change on the perimeter of the star, and they lie along either the
inner or the outer circle, as shown above. The method
getOuterPoint() returns the coordinates of points on the
outer circle while getInnerPoint() returns the coordinates
of points on the inner circle. In both cases, the coordinates are
returned in the form of a
Point object. An Example of a call to
getOuterPoint() and getInnerPoint() is:
PloyStar star1 = new PolyStar(100, 100, 80, 5);
// get the coordinates of point 0 on the outer circle
Point Outie = star1.getOuterPoint(0);
// get the coordinates of point 0 on the inner circle
Point Innie = star1.getInnerPoint(0);
You will find it useful (but not required) to use the getOuterPoint() and getInnerPoint() methods to acquire the x and y coordinates that are input to fillPolygon() when drawing a star.
Note that 10% of your program grade is based on the readability of your program. This includes things like proper indentation, comments, and the naming of variables and methods. To receive full credit for your program, make sure that you use proper indentation as demonstrated in your text and in class room examples. Also include a comment at the top of each program stating your name, the course, and the purpose of the program:
The program written for this assignment must be turned in by transferring the java source code file and the HTML file to your ftp directory for this class. Both the source code file (i.e., Star.java) and the HTML file (Star.html) should be turned in and the files must have exactly those names. You were shown how to transfer files to your class ftp directory in lab 1