Answered step by step
Verified Expert Solution
Link Copied!

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

image


(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 ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Structures and Algorithms in Java

Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser

6th edition

1118771334, 1118771338, 978-1118771334

More Books

Students also viewed these Programming questions

Question

6. Which types of memory are least impaired in people with amnesia?

Answered: 1 week ago

Question

18. What kind of cell releases cytokines?

Answered: 1 week ago