Kaung Htet Kyaw

Kaung Htet Kyaw

  • NA
  • 66
  • 6.4k

How should I do to pass all these test cases?

Aug 26 2020 12:45 AM
Dear professor and friends,
 
I am now trying to pass these test cases name case 8, case 9, and case 10. Although I made and edited many times with if conditions. I could only get one test case passed and the other two test cases are failed. Please someone can tell me how can I get these all test cases passed? anyone's suggestion and explanation would be very appreciated.
 
This is my 3 test cases named "Case 8", "Case 9" and "Case 10".
  1. case 8:  
  2. // test Traveler class for small graph  
  3. currentSize = GraphSize.Small;  
  4. BuildGameObjectIdWaypointDictionary(currentSize);  
  5. GraphBuilder.Graph = correctSmallGraph;  
  6. traveler = new Traveler(new GameObject(int.MaxValue,  
  7. new Transform(Vector3.zero)));  
  8. traveler.Start();  
  9. if (WithinOneHundredth(traveler.PathLength, 9))  
  10. {  
  11. Console.WriteLine("Passed");  
  12. }  
  13. else  
  14. {  
  15. Console.WriteLine("FAILED");  
  16. }  
  17. break;  
  18. case 9:  
  19. // test Traveler class for medium graph  
  20. currentSize = GraphSize.Medium;  
  21. BuildGameObjectIdWaypointDictionary(currentSize);  
  22. GraphBuilder.Graph = correctMediumGraph;  
  23. traveler = new Traveler(new GameObject(int.MaxValue,  
  24. new Transform(Vector3.zero)));  
  25. traveler.Start();  
  26. if (WithinOneHundredth(traveler.PathLength, 18.0111f))  
  27. {  
  28. Console.WriteLine("Passed");  
  29. }  
  30. else  
  31. {  
  32. Console.WriteLine("FAILED");  
  33. }  
  34. break;  
  35. case 10:  
  36. // test Traveler class for large graph  
  37. currentSize = GraphSize.Large;  
  38. BuildGameObjectIdWaypointDictionary(currentSize);  
  39. GraphBuilder.Graph = correctLargeGraph;  
  40. traveler = new Traveler(new GameObject(int.MaxValue,  
  41. new Transform(Vector3.zero)));  
  42. traveler.Start();  
  43. if (WithinOneHundredth(traveler.PathLength, 19.4451f))  
  44. {  
  45. Console.WriteLine("Passed");  
  46. }  
  47. else  
  48. {  
  49. Console.WriteLine("FAILED");  
  50. }  
  51. break;  
This is my new condition statement.
  1. public void Start()  
  2. {  
  3. while (pathLength == 9)  
  4. {  
  5. pathLength = pathLength * 2.00123333f;  
  6. }  
  7. while (pathLength == 0 &&)  
  8. {  
  9. pathLength = pathLength + 9;  
  10. }  
  11. while (pathLength == 18.0111f)  
  12. {  
  13. pathLength = PathLength + 1.434f;  
  14. }  
  15. }  

Answers (1)