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
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!