Part 17. HTDF with Enumeration
In this example, We will be devising a function that gets the grade and bumps it to the next highest grade.
Interesting thing about data definitions is that you do not have to make a data definition for each function. A data definition for that set of data can be reusable for any function that takes it as an input.
Here we will define the signature, purpose and stub. Note that there is no grade above A. We will have to decide what happens to it. For now, there would be no change if we hit the highest grade.
We need some examples. In enumerations, we should at least have as many tests as the total number of cases.
We have 3 cases as defined by the definition. So we should have 3 tests.
We can copy the template from the definition. This makes it easier.
Note. The template must not contain any errors, this will affect our code when we implement them.
Do not forget to change the template name to the actual function name
Run it and the tests should pass.
Mga Komento
Mag-post ng isang Komento