First, the purpose of the experiment
1. Initial mastery of unit testing and TDD
2. Understanding and mastering the object-oriented three elements: encapsulation, inheritance, polymorphism
3. Initial mastery of UML modeling
4. Familiarity with S.O.L.I.D principles
5. Understanding Design Patterns
Ii. contents of the experiment
(a) Unit testing
Pseudo-code: independent of the specific programming language, is the most natural product code, the best comment.
Product Code
Test code
Experimental steps:
In a myutil class to solve a percentile score into "excellent, good, medium, pass, fail" five Grade system performance function
The first step: write the percentile five-point pseudo-code as follows:
If the score is less than 60, turn into "fail"
If the score is between 60 and 70, turn into "pass"
If the score is between 70 and 80, turn into "medium"
If the score is between 80 and 90, turn into "good"
If the score is between 90 and 100, turn into "good"
Other, turn into "error"
The second step: write the test code (including test boundary values and exceptions) as follows:
The third step: write the product code as follows:
Run it and if you find that the error improves the product code according to the error, the operation succeeds.
From the above, the TDD method has successfully implemented the product code
Experiment two Java object-oriented programming