Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Create a Pen class and integrate it into Turtle.

1 vue (au cours des 30 derniers jours)
Estefania Dimas Martinez
Estefania Dimas Martinez le 17 Oct 2016
Clôturé : John D'Errico le 17 Oct 2016
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);

Réponses (0)

Cette question est clôturée.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by