ผลต่างระหว่างรุ่นของ "01219343/unit/triangle"

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
(หน้าที่ถูกสร้างด้วย '== Part I == Write unit tests for <code>Triangle.checkType</code>. Download [http://theory.cpe.ku.ac.th/wiki/images/343-lect02triangl...')
 
 
(ไม่แสดง 2 รุ่นระหว่างกลางโดยผู้ใช้คนเดียวกัน)
แถว 1: แถว 1:
 +
: ''This exercise is part of [[01219343-55]].''
 +
 
== Part I ==
 
== Part I ==
  
แถว 6: แถว 8:
  
 
You would also want <code>checkType</code> to check for '''right triangles.'''  A right triangle is a triangle whose one of its interiror angle measure 90 degrees.
 
You would also want <code>checkType</code> 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 <code>checkType</code>?
 +
 +
Modify <code>enum Type</code> to include <code>Right</code>, and modify the function to work with right triangles.
 +
 +
Write a few more test cases for <code>checkType</code>.
 +
 +
== 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 <code>checkType</code> to raise an exception.
 +
 +
Modify <code>checkType</code> so that it can check for this non-triangle case, and add more unit test cases for this.

รุ่นแก้ไขปัจจุบันเมื่อ 16:34, 24 มกราคม 2556

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.