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
1
2
6
import static org.junst.Assert.
*
;
public class ProductTest
{
@Test
public void testpriceVar
(
)
{
Product prod
=
new Product
(
"
Dr
.
Pepper",
1
.
2
5
)
;
double expected
=
1
.
2
5
double actual
=
prod.getprodprice
(
)
:
}
asserteguals
(
expected
,
actual,
0
)
;
@test
public void testPriceVarForlessThanzero
(
)
{
Product prod
=
new Product
(
"
Dr
.
Pepper",
-
1
.
9
9
)
;
double expested
=
0
.
2
5
;
double actual
=
prodogetprodprice
(
)
;
}
asserteguals
(
expected
,
astual, O
)
;
(
This is the main method
)
v
cackgge Junit
_
testing
_
Jtorres
1
2
6
;
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
3
public static void main
(
String
[
]
args
)
{
Product
1
=
new Product
(
)
:
p
1
.
setprodPrice
(
-
2
0
)
;
}
System.out.printin
(
p
1
.
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
0
)
{
3
thisoprodprice
=
0
.
2
5
8
}
3
.
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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!