Info

此问题已关闭。 请重新打开它进行编辑或回答。

Create a Pen class and integrate it into Turtle.

1 次查看(过去 30 天)
Create a Pen class and integrate it into Turtle. Instead of having the Turtle remember the color and width of the pen, just give the Turtle a pen object to use. properties … pen_color % deleted pen_width % deleted pen % added ... end The Pen class should have properties color and width and methods Pen(), setColor(), setWidth(). Add a setPen() method to Turtle to handle changing the Turtle’s pen. You will also need to make small modifications to your other code to reflect the fact that the Turtle has a Pen object as a property. You can now define Pens the Turtle can use. For example: thick_red = Pen(); thick_red = thick_red.setColor(‘red’); thick_red = thick_red.setWidth(5); thin_blue = Pen(); thin_blue = thin_blue.setColor(‘blue’); thin_blue = thin_blue.setWidth(1); turtle = turtle.setPen(thick_red); … turtle = turtle.setPen(thin_blue);

回答(0 个)

此问题已关闭。

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by