don't transfer to Computer engineering tutors they are not answering please try it yourself Consider the Java class Slice The objects of Slice are created with a weight. public class Slice { private double weight; /** postcondition: this.weight takes the absolute value of weight. If weight is < 0.5 then this.weight takes value 5. */ public Slice(double weight) { this.weight = weight; if (weight < 0) { this.weight = Math.abs(weight); } if (weight < 0.5){ this.weight = 0.5; } } public double getWeight() { return this.weight; } public double getPrice(double pricePG) { /** TODO pricePG (price per gram) is >= 0 and it goes in increments of 0.5. weight is >= 0.5. Returns the price of the slice as its weight multiplied by the */ } } Class Slice offers a constructor method, a getter method for weight, and method getPrice that calculates the price of a slice. Assume you are developing a jUnit test for class Slice. Answer the questions below. You wish to develop a fixture for method testSlice(), to test method Slice(). Say which objects you would create in the fixture, to ensure 100% decision coverage for Slice(). The number of objects you choose should be minimal. Justify your answer. Use equivalence class partitioning to define the set of states (i.e., fixture and input values for the parameter pricePG) for testing getPrice(). You need to show how you derived that state. Note that the code of getPrice() is not given because it is not necessary for the application of equivalence class partitioning. You can rely on the information in the code comments of method getPrice() to answer this question. Write a method testGetPrice() that tests getPrice(), checking that the returned price: (i) is positive, (ii) is calculated correctly. Note: use one (only one for simplicity) of the slice objects in the fixture and one of the values for pricePG you identified in your answer to b(ii). You can answer by building on the template public void testCircumference() { … }
don't transfer to Computer engineering tutors they are not answering please try it yourself
- Consider the Java class Slice The objects of Slice are created with a weight.
public class Slice {
private double weight;
/**
- postcondition: this.weight takes the absolute value
- of weight. If weight is < 0.5 then this.weight takes
- value 5.
*/
public Slice(double weight) { this.weight = weight; if (weight < 0) {
this.weight = Math.abs(weight);
}
if (weight < 0.5){
this.weight = 0.5;
}
}
public double getWeight() {
return this.weight;
}
public double getPrice(double pricePG) {
/**
- TODO
- pricePG (price per gram) is >= 0 and
- it goes in increments of 0.5. weight
- is >= 0.5. Returns the price of the slice
- as its weight multiplied by the
*/
}
}
Class Slice offers a constructor method, a getter method for weight, and method getPrice that calculates the price of a slice. Assume you are developing a jUnit test for class Slice. Answer the questions below.
- You wish to develop a fixture for method testSlice(), to test method Slice(). Say which objects you would create in the fixture, to ensure 100% decision coverage for Slice(). The number of objects you choose should be
minimal. Justify your answer.
- Use equivalence class partitioning to define the set of states (i.e., fixture and input values for the parameter pricePG) for testing getPrice(). You need to show how you derived that state. Note that the code of getPrice() is not given because it is not necessary for the application of equivalence class partitioning. You can rely on the information in the code comments of method getPrice()
to answer this question.
- Write a method testGetPrice() that tests getPrice(), checking that the returned price: (i) is positive, (ii) is calculated correctly. Note: use one (only one for simplicity) of the slice objects in the fixture and one of the values for pricePG you identified in your answer to b(ii). You can answer by building on the template
public void testCircumference() {
…
}
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)