Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(b) The following snippet shows a Java method that takes a football score (for teams A and B) and reports the current match status
(b) The following snippet shows a Java method that takes a football score (for teams A and B) and reports the current match status ("A is winning", "B is winning" or "It's a draw!"). The code contains one error. On line 3, the condition checks whether the value of "b" is greater than zero, rather than checking if it is greater than "a". 01: String formatScore (int a, int b) { 02: if (a > b) return String.format ("A is winning!"); 03: if (b > 0) return String.format("B is winning!"); 04: return String.format("It is a draw!"); 05: ) (1) Use equivalence class partitioning to design a set of tests for the . method that covers all possible classes of inputs. Give a table with input values (for a and b) and the expected result. Do your tests find the error in the code? (ii) Consider the tests designed in (i). Is it possible to give a table that answers the question (i) correctly, but does not actually reveal the error in the code? Explain your answer. (iii) Now we want to use property-based testing to test the code. To test the case for when the state is a draw, we use the following jawik test that takes arbitrary value "n" in range from 0 to 100. Complete the test by filling-in the placeholder "...": @Property boolean clever_property ( @ForAll @IntRange (min=0, max=100) int n) { return ...;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
a Java method that takes a football score for teams A and B and reports the current match status However the code contains an error The error is on line 3 where the condition checks whether the value ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started