(b) The following snippet shows a Java method that takes a football score (for teams A...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(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 ...; (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 ...;
Expert Answer:
Answer rating: 100% (QA)
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 ... View the full answer
Related Book For
Data Structures and Algorithms in Java
ISBN: 978-1118771334
6th edition
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser
Posted Date:
Students also viewed these programming questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
In the conversion of a-ketoglutarate to glucose, which of the following compounds are not obligatory intermediates in this pathway? * Oxaloacetate O Fructose 1,6 bisphosphate O Malate O 1,3...
-
Common tests such as the SAT, ACT, Law School Admission test (LSAT), and Medical College Admission Test (MCAT) use multiple choice test questions, each with possible answers of a, b, c, d, e, and...
-
What five factors determine your credit score, and how are these factors weighted by BEACON?
-
Is it possible for the kinetic energy of an object to remain constant even when the vector sum of the forces exerted on the object is not zero? If yes, give an example. If no, explain why not.
-
Ornamental Iron Works began January with 45 units of iron inventory that cost $24 each. During January, the company completed the following inventory transactions: Requirements 1. Prepare a perpetual...
-
1. The table on the right shows the most current government economic indicators. How much did the average living standards increase in the US in 2015. Year GDP in billions of current dollars Real...
-
The Man In the Arena by Theodore Roosevelt (From a speech delivered in Paris in 1910) It is not the critic who counts, not the man who points out how the strong man stumbled, or where the doer of...
-
After intensive market research and having saved enough money to open your own food delivery service, you enter into a contract with a fresh produce caterer. The caterer agrees to supply all the...
-
To complete this part of the assessment, you will create an agency profile. Scenario Azure Beach Realty Group (ABRG) is a real estate group on the south coast of New South Wales and has two agencies,...
-
Marvin Gaye owns a business. Jeffrey Osborne bought 100 widgets from him. To pay for the widgets he issued a note, payable to Marvin Gaye. The note provides that "I, Jeffrey Osborne, promise to pay...
-
Examine the following C++ program and give its output. (1 mark). #include #include #include using namespace std; void search vector & vec, int val) { } cout < < "searching for " < < val < < " ... ";...
-
Select a familiar business or find a business by conducting an Internet search. Identify the selected business' structure using the business structures identified in your text, course materials, and...
-
What is the CSS statement to make all the color of elements blue? Select one: O a. O b. O c. all other answers are wrong O d. p{color:blue }
-
Prairie Outfitters, Inc., a retailer, accepts paymnent through credit cards. During August, credit card sales amounted to $12,000. The processor charges a 3% fee. Assuming that the credit card...
-
Modify the Pair class from Code Fragment 2.17 on page 92 so that it provides a natural definition for both the equals( ) and hashCode( ) methods.
-
Illustrate all the steps of the adaptable priority queue call replaceKey(e, 18) for entry e storing (5, A) in the heap of Figure 9.1. (4,C) (5,A) (6,Z) (15,) (9,F) (7,Q) (20,B) (16,X) (25,J) (14,E)...
-
Add support in LinkedBinaryTree for a method, swap(p, q), that has the effect of restructuring the tree so that the node referenced by p takes the place of the node referenced by q, and vice versa....
-
Which of Yellows statements regarding the factors affecting the selection of a trading strategy is correct? A. Statement 1 B. Statement 2 C. Statement 3 Robert Harding is a portfolio manager at...
-
To fill the remaining portion of the ABC order, Yellow is using: A. an arrival price trading strategy. B. a TWAP participation strategy. C. a VWAP participation strategy. Robert Harding is a...
-
Given the parameters for the benchmark given by Harding, Yellow should recommend a benchmark that is based on the: A. arrival price. B. time-weighted average price. C. volume-weighted average price....
Study smarter with the SolutionInn App