Question: c . Make sure there are no syntax errors then press the green Run button at the top of Eclipse. We see that one of
c
Make sure there are no syntax errors then press the green Run button at the top of Eclipse. We see that one of our test passed and one failed. And in the Failure trace, we see the expected and the actual results.
f
Fix the setProdPrice
double
method of the Product class so it handles values less than zero as described by our rules. Think about if you are not setting the value to check, so You need need to figure out where to add the change.
Tips: Constructor
g
Make sure there are no syntax errors then press the green Run button at the top of Eclipse. Did both test pass this time?
h
Commit your code to the GitHub repo.
This is the Junit test code
v
package junit
testing Jtorres
import static org.junst.Assert.
;
public class ProductTest
@Test
public void testpriceVar
Product prod
new Product
Dr
Pepper",
;
double expected
double actual
prod.getprodprice
:
asserteguals
expected
actual,
;
@test
public void testPriceVarForlessThanzero
Product prod
new Product
Dr
Pepper",
;
double expested
;
double actual
prodogetprodprice
;
asserteguals
expected
astual, O
;
This is the main method
v
cackgge Junit
testing
Jtorres
;
pubize ciass
q
private string prodName;
private double prodPrices
private int prodQty;
public Product
String prodName, double prodPrice
constructor
this prodName
prodName;
this. prodPrice
prodPrice ;
public Product
no acgs constructor
public static void main
String
args
Product
new Product
:
p
setprodPrice
;
System.out.printin
p
getProdPrice
public String getProdName
return prodNames
public void setprodName
String prodName
this.prodiame
prodivames
public double getprodPrice
return prodprices
public void setprodprice
double prodprice
f
if
prodprice
thisoprodprice
else
this. prodPrice
prodPrices
public int getiprodoty
return prodotys
public void setprodoty
int prodety
this prodety
prodety
s
public string tostring
return this, getProdName
"this.getProdPrice
;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
