Milestone 003: Shapes and Random Color #32

Merged
Tirsvad merged 3 commits from mil-003-shapes-and-random-color into mil-002-square-and-dashed-line 2026-10-07 18:42:30 +02:00
3 changed files with 11 additions and 1 deletions
Showing only changes of commit c695c47929 - Show all commits
+4 -1
View File
@@ -75,8 +75,9 @@ python -m turtle_challenges dashed-line
| --- | --- | --- | | --- | --- | --- |
| 1. Draw a square | `turtle-challenges square` | `draw_square` | | 1. Draw a square | `turtle-challenges square` | `draw_square` |
| 2. Draw a dashed line | `turtle-challenges dashed-line` | `draw_dashed_line` | | 2. Draw a dashed line | `turtle-challenges dashed-line` | `draw_dashed_line` |
| 3. Draw different shapes | `turtle-challenges shapes` | `draw_shape`, `draw_shapes`, `random_color` |
Challenges 3 to 5 are added by milestones 003 and 004. Challenges 4 and 5 are added by milestone 004.
`turtle-challenges --help` lists the challenges. If the command prints that the turtle module needs Tk, install Tk as described under Requirements. `turtle-challenges --help` lists the challenges. If the command prints that the turtle module needs Tk, install Tk as described under Requirements.
@@ -132,8 +133,10 @@ Open `build/html/index.html` in a browser. Any Doxygen warning fails the build,
│ ├── constants.py every constant of the project │ ├── constants.py every constant of the project
│ ├── pen.py the Pen and Window protocols the challenges use │ ├── pen.py the Pen and Window protocols the challenges use
│ ├── window.py opens the turtle window and creates the turtle │ ├── window.py opens the turtle window and creates the turtle
│ ├── colors.py random_color and random_palette_color
│ ├── square.py challenge 1: draw_square │ ├── square.py challenge 1: draw_square
│ ├── dashed_line.py challenge 2: draw_dashed_line │ ├── dashed_line.py challenge 2: draw_dashed_line
│ ├── shapes.py challenge 3: draw_shape, draw_shapes
│ └── cli.py the turtle-challenges command │ └── cli.py the turtle-challenges command
├── tests/ pytest tests and the recording fake pen ├── tests/ pytest tests and the recording fake pen
├── Doxyfile Doxygen configuration ├── Doxyfile Doxygen configuration
+3
View File
@@ -10,10 +10,12 @@ from functools import partial
from turtle_challenges.constants import ( from turtle_challenges.constants import (
CHALLENGE_DASHED_LINE, CHALLENGE_DASHED_LINE,
CHALLENGE_NAMES, CHALLENGE_NAMES,
CHALLENGE_SHAPES,
CHALLENGE_SQUARE, CHALLENGE_SQUARE,
) )
from turtle_challenges.dashed_line import draw_dashed_line from turtle_challenges.dashed_line import draw_dashed_line
from turtle_challenges.pen import Pen from turtle_challenges.pen import Pen
from turtle_challenges.shapes import draw_shapes
from turtle_challenges.square import draw_square from turtle_challenges.square import draw_square
from turtle_challenges.window import ( from turtle_challenges.window import (
TurtleUnavailableError, TurtleUnavailableError,
@@ -52,6 +54,7 @@ def build_challenges(pen: Pen) -> dict[str, Callable[[], None]]:
return { return {
CHALLENGE_SQUARE: partial(draw_square, pen), CHALLENGE_SQUARE: partial(draw_square, pen),
CHALLENGE_DASHED_LINE: partial(draw_dashed_line, pen), CHALLENGE_DASHED_LINE: partial(draw_dashed_line, pen),
CHALLENGE_SHAPES: partial(draw_shapes, pen),
} }
+4
View File
@@ -68,8 +68,12 @@ CHALLENGE_SQUARE = "square"
## Command line name of challenge 2. ## Command line name of challenge 2.
CHALLENGE_DASHED_LINE = "dashed-line" CHALLENGE_DASHED_LINE = "dashed-line"
## Command line name of challenge 3.
CHALLENGE_SHAPES = "shapes"
## Names of the challenges on the command line, in the order of the course. ## Names of the challenges on the command line, in the order of the course.
CHALLENGE_NAMES: tuple[str, ...] = ( CHALLENGE_NAMES: tuple[str, ...] = (
CHALLENGE_SQUARE, CHALLENGE_SQUARE,
CHALLENGE_DASHED_LINE, CHALLENGE_DASHED_LINE,
CHALLENGE_SHAPES,
) )