[v3] Implement new Concept Exercise: numbers
- 主要語言
- C++
- 星號
- 290
- 分支
- 244
- PR 合併指標
- 30 天內沒有已合併 PR
描述
This issue describes how to implement the `numbers` concept exercise for the C++ track.
## Getting started
**Please please please read the docs before starting.** Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:
- [The features of v3](https://github.com/exercism/v3/blob/master/docs/concept-exercises.md).
- [Rationale for v3](https://github.com/exercism/v3/blob/master/docs/rationale-for-v3.md).
- [What are concept exercise and how they are structured?](https://github.com/exercism/v3/blob/master/docs/features-of-v3.md)
Please also watch the following video:
- [The Anatomy of a Concept Exercise](https://www.youtube.com/watch?v=gkbBqd7hPrA).
## Goal
The goal of this exercise is to teach the student how to deal with `numbers` in C++.
## Learning objectives
- Know of the existence of the two most basic number types, `int` and `double`, and understand that the former represents integer numbers, and the latter floating-point numbers.
- Know of basic operators, e.g. adding, multiplying, etc.
- Know where it's documented and how to search for it.
## Out of scope
- Overflows.
- Casting `int` to `double` and vice versa.
- Parsing `string` to an `int` or `double`.
- Converting `int` or `double` to a `string`.
- Any other integral types besides `int` and `double`, e.g. `short int`,, `long double` and other modifiers.
## Concepts
- `numbers-basic`
## Prequisites
There are no prerequisites.
## Resources to refer to
### Hints
- [Variables and types](https://www.cplusplus.com/doc/tutorial/variables/)
- [Operators](https://www.cplusplus.com/doc/tutorial/operators/)
### After
- [Data Types](https://www.tutorialspoint.com/cplusplus/cpp_data_types.htm)
- [Fundamental types](https://en.cppreference.com/w/cpp/language/types)
- [Variables and types](https://www.cplusplus.com/doc/tutorial/variables/)
- [Operators](https://www.cplusplus.com/doc/tutorial/operators/)
## Representer
There is no representer at this moment.
## Analyzer
There is no analyzer at this moment.
## Implementing
If you'd like to work on implementing this exercise, the first step is to let us know through a comment on this issue, to prevent multiple people from working on the same exercise. If you have any questions while implementing the exercise, please also post them as comments in this issue.
To implement a concept exercise, the following files must be created:
languages
└── cpp
└── exercises
└── concept
└── numbers
├── .docs
│ ├── after.md
│ ├── hints.md
│ ├── instructions.md
│ └── introduction.md
├── .meta
| |── config.json
│ ├── design.md
│ ├── example.cpp
│ └── example.h
├── CMakeLists.txt
├── numbers.cpp
├── numbers.h
├── numbers_test.cpp
└── test
├─- catch.hpp
└── tests_main.cpp
## Step 1: add .docs/introduction.md
This file contains an introduction to the concept. It should make the exercise's learning goals explicit and provide a short introduction with enough detail for the student to complete the exercise. The aim is to give the student just enough context to figure out the solution themselves, as research has shown that self-discovery is the most effective learning experience. Using the proper technical terms in the descriptions will be helpful if the student wants to search for more information. If the exercise introduces new syntax, an example of the syntax should always be included; students should not need to search the web for examples of syntax.
As an example, the introduction to a "strings" exercise might describe a string as just a "Sequence of Unicode characters" or a "series of bytes". Unless the student needs to understand more nuanced details in order to solve the exercise, this type of brief explanation (along with an example of its syntax) should be sufficient information for the student to solve the exercise.
## Step 2: add .docs/instructions.md
This file contains instructions for the exercise. It should explicitly explain what the student needs to do (define a method with the signature `X(...)` that takes an A and returns a Z), and provide at least one example usage of that function. If there are multiple tasks within the exercise, it should provide an example of each.
## Step 3: add .docs/hints.md
If the student gets stuck, we will allow them to click a button requesting a hint, which shows this file. This will not be a "recommended" path and we will (softly) discourage them using it unless they can't progress without it. As such, it's worth considering that the student reading it will be a little confus fileed/overwhelmed and maybe frustrated.
The file should contain both general and task-specific "hints". These hints should be enough to unblock almost any student. They might link to the docs of the functions that need to be used.
The hints should not spell out the solution, but instead point to a resource describing the solution (e.g. linking to documentation for the function to use).
## Step 4: add .docs/after.md
Once the student completes the exercise they will be shown this file, which should provide them with a summary of what the exercise aimed to teach. This document can also link to any additional resources that might be interesting to the student in the context of the exercise.
See the C++ strings exercise's [after.md][example-after-md] file for an example.
## Step 5: update languages/cpp/config.json
An entry should be added to the track's `config.json` file for the new concept exercise:
```json
{
...
"exercises": {
"concept": [
...
{
"slug": "numbers",
"uuid": "fe54c2f6-f2e9-4bb0-bca4-de74663be16f",
"concepts": ["numbers-basic"],
"prerequisites": []
}
]
}
}
```
## Step 6: adding track-specific files
These files are specific to the C++ track:
- `numbers.h` and `numbers.cpp`. the stub implementation files, which is the starting point for students to work on the exercise.
- `CMakeLists.txt`: the C++ project file.
- `numbers_test.cpp`: the test suite.
- `.meta/example.h` and `.meta/example.cpp`: an example implementation that passes all the tests.
- `test/catch.hpp`: single-header testing library.
- `test/tests_main.cpp`: generates test main from test library
## Step 7: updating list of implemented exercises
- Add the exercise to the [list of implemented exercises][implemented-exercises].
## Step 8: add .meta/design.md:
This file contains information on the exercise's design, which includes things like its goal, its teaching goals, what not to teach, and more ([example][meta-design]). This information can be extracted from the exercise's corresponding GitHub issue.
## Step 9: add .meta/config.json:
This file contains meta information on the exercise, which currently only includes the exercise's contributors ([example][meta-config-json]).
## Inspiration
When implementing this exercise, it can be very useful to look at [already implemented C++ exercises][implemented-exercises].
## Help
If you have any questions regarding implementing the exercise, please post them as comments in the exercise's GitHub issue.
[example-after-md]: https://github.com/exercism/v3/blob/master/languages/cpp/exercises/concept/strings/.docs/after.md
[implemented-exercises]: https://github.com/exercism/v3/blob/master/languages/cpp/exercises/concept/README.md
[meta-design]: https://github.com/exercism/v3/blob/master/languages/cpp/exercises/concept/strings/.meta/design.md
[meta-config-json]: https://github.com/exercism/v3/blob/master/languages/cpp/exercises/concept/strings/.meta/config.json
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。