01219343/unit/triangle

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
This exercise is part of 01219343-55.

Part I

Write unit tests for Triangle.checkType. Download source code

Part II

You would also want checkType to check for right triangles. A right triangle is a triangle whose one of its interiror angle measure 90 degrees.

Question: Is there any ambiguity in the requirement for checkType?

Modify enum Type to include Right, and modify the function to work with right triangles.

Write a few more test cases for checkType.

Part III

Not all combinations of side lengths correspond to triangles. For example, if your side lengths are 1,3, and 10, there is no triangle with that side lengths. When this occurs, you want checkType to raise an exception.

Modify checkType so that it can check for this non-triangle case, and add more unit test cases for this.