0:00
Okay.
00:02
So for the inside regular polygon problem, basically we're just going to be taking our solution from problem 20, which had the regular polygon canvas and just adapted a little bit so that it makes it easy to add or remove a side and then redraw the polygon after we've added or removed aside.
00:28
So what i've done here is we've broken out the drawing part of the regular polygon canvas into its own function.
00:38
This will just find all the points of the polygon.
00:44
It'll delete anything that was previously drawn on the canvas and then redraw the polygon.
00:50
We also made some accessor methods for the number of sides attribute.
00:57
This way when we set the number of sides, we can redraw the polygon with that number of sides.
01:08
For our application, after we create the polygon canvas, we're going to create two helper methods that can add or remove a side, and then we're going to bind it to all of the various controls that they want to be able to use to increment or decrement the sides.
01:29
For adding a side, we're just going to call self .polygon.
01:36
Set number of sides, and then set, we're going to set the number of sides equal to the current number of sides plus one.
01:49
For remove a side, we're going to be the same thing, except it's going to be minus one.
01:57
We have this event, this optional event parameter, so that we can use it as a binding and as a button control.
02:08
And then to set up all the buttons and bindings we can do, we'll add a small frame for the buttons, so they can have them side by side.
02:24
B1 equals button.
02:28
It's going to be in the buttons frame.
02:34
Command equals self -ad side...