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() {   …   }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

don't transfer to Computer engineering tutors they are not answering please try it yourself

  1. 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() {

 

 

}             

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY