diff --git a/client/i18n/locales/english/intro.json b/client/i18n/locales/english/intro.json index 200e223eb65..7ead750b2b8 100644 --- a/client/i18n/locales/english/intro.json +++ b/client/i18n/locales/english/intro.json @@ -6206,6 +6206,12 @@ "In these lessons, you will learn how to work with union types, interfaces, void types and more." ] }, + "workshop-shape-manager": { + "title": "Build a Shape Manager", + "intro": [ + "In this workshop, you will practice basic TypeScript features like types and interfaces by building a shape manager program." + ] + }, "lecture-working-with-generics-and-type-narrowing": { "title": "Working with Generics and Type Narrowing", "intro": [ diff --git a/curriculum/challenges/english/blocks/workshop-shape-manager/68ff37f55fb2122df640cd78.md b/curriculum/challenges/english/blocks/workshop-shape-manager/68ff37f55fb2122df640cd78.md new file mode 100644 index 00000000000..39af5447be8 --- /dev/null +++ b/curriculum/challenges/english/blocks/workshop-shape-manager/68ff37f55fb2122df640cd78.md @@ -0,0 +1,326 @@ +--- +id: 68ff37f55fb2122df640cd78 +title: Step 11 +challengeType: 0 +dashedName: step-11 +--- + +# --description-- + +You have a working circle area calculation logic now. You can type in a radius and see the area update instantly. + +However, if you continue writing this way for rectangles and triangles, things will become a clutter of loose variables and repeated logic. To prevent this, you can structure the data using **interfaces**, and create a function that handles all area calculation cases. + + +An interface defines the structure of an object by specifying its property types. Here's what an interface looks like in Typescript. + +```ts +interface Footballer { + name: string; + age: number; + isCaptain: boolean; +} +``` + +Create a base interface named `Shape`. Inside it, set `type` to `string`. + +# --hints-- + +You should have an interface named `Shape`. + +```js +const explorer = await __helpers.Explorer(code); +assert.exists(explorer.interfaces.Shape); +``` + +Your `Shape` interface should have a `type` set to `string`. + +```js +const explorer = await __helpers.Explorer(code); +const { Shape } = explorer.interfaces; +const prop = { name: "type", type: "string" }; +assert.isTrue(Shape.hasTypeProps(prop)); +``` + +# --seed-- + +## --seed-contents-- + +```html + + +
+ + + +Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+Calculate areas of geometric shapes
+