triangle exercise
play

Triangle Exercise { Triangle Classification [ Myers] [ M ] A - PDF document

{bnielsen@cs.aau.dk} } Brian Nielsen Triangle Exercise { Triangle Classification [ Myers] [ M ] A program reads three integer values. The A d th i t l Th three values are interpreted as representing the lengths of the sides


  1. {bnielsen@cs.aau.dk} } Brian Nielsen Triangle Exercise {

  2. Triangle Classification [ Myers] [ M ]  “A program reads three integer values. The “A d th i t l Th three values are interpreted as representing the lengths of the sides of a triangle. The g g program prints a message that states whether the triangle is scalene, isosceles, or equilateral ” equilateral.  Write a set of test cases to test this program Input Input Expected Expected data output 5,5,5 , , equilateral q … CISS

  3. Triangle Classification g [ Myers] Test cases for: 9. one side larger than sum of 1. 1 valid scalene triangle ? lid l t i l ? others ? 2. valid equilateral triangle ? 10. 3 permutations of previous ? 3. valid isosceles triangle ? 11. all sides = 0 ? 4. 3 permutations of previous ? 12. non-integer input ? 5. side = 0 ? 13. wrong number of values ? 6 6. negative side ? negative side ? 14. for each test case: is 14 for each test case: is expected output specified ? 7. one side is sum of others ? 15. check behaviour after 8. 3 permutations of previous ? output was produced ? t t d d ? CISS

  4. TDD E TDD Exercise i  Develop a program that classifies triangles according to the given specification using TDD, i.e.  TEST FI RST+ xUnit Testing  Get started with supplied skeleton CISS

  5. N New Requirem ent R i t  Don’t peek: complete the former step first!!  The program must also be able to classify The program must also be able to classify “Rectangular” triangles CISS

  6. N New Requirem ent R i t  Don’t peek: complete the former step first!! D ’t k l t th f t fi t!!  The program must print out meaningful error  The program must print out meaningful error messages why a given input is invalid.  “ The sides (a= 1,b= 2,c= 9) is not a valid triangle ( , , ) g because c is greater that the sum of a and b”  The program must print out meaningful explanations why a given triangle is a particular explanations why a given triangle is a particular type  “ The sides (a= 5,b= 13,c= 12) is a rectangular triangle because a squared plus c squared equals b squared” b d l d l b d” CISS

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend