Lesson 9 - More OOP
DIY - Creating Fib Class (10 minutes)

create a Fib class that can run the following code:
Solution
Creating an IntList

another example
Polygon (Point list)


Lets change a few properties of our IntList and create a PointList
we will add a few fields
Color color
String name
and a method to convert the the x and y to a list of double
double[] convert2DoubleArray(String x_or_y)
Drawing the polygon

Lets now draw a Polygon (Point list with at least 3 points + the first point to close the loop)
The points in the polygon are (x[i], y[i]). For example, the following code fragment draws a filled diamond with vertices (0.1, 0.2), (0.2, 0.3), (0.3, 0.2), and (0.2, 0.1):
so we need to add the following function to Polygon

or

Last updated
Was this helpful?