Question: I am creating class name RideRequest where I have given few test to check my code. I am able to pass almost all the test
I am creating class name RideRequest where I have given few test to check my code. I am able to pass almost all the test except few of them Please help me figure out where i am doing wrong these are instance variable of RideRequest class
private String customerName;
private String rideDetails;
private double ridePrice;
private boolean hasDiscount;
private static double taxrate;
private static double discount;
private static int toStringCounter ;
I am having issue with last one toStringCounter where i need to increase its count with every jUnit test there are total jUnit test related to ToStringCounter where i need to print expected output I am able to do all the calculations and had figured out what spacing need to be done to get expected output that aligns with JUnit test but with every test running my counter is not incerasing its value keep remains to one Please help me figure what chnage do i need to make to get following output right
this first test i got it rigth public void test
RideRequest request new RideRequest Kate Woodbine Y ;
RideRequest.setTaxrate; Assuming tax rate
RideRequest.setDiscount; Assuming discount rate
String expectedOutput Kate Woodbine ;
assertEqualstoString method failed", expectedOutput, request.toString;
but when second test run my counter does not increse and its value remains to here is second testpublic void test
RideRequest request new RideRequest Susan Mississauga Y ;
RideRequest.setTaxrate; Assuming tax rate
RideRequest.setDiscount; Assuming discount rate
String expectedOutput Susan Mississauga ;
assertEqualstoString method failed", epublic void test
RideRequest request new RideRequest Jack North York N ;
RideRequest.setTaxrate; Assuming tax rate
RideRequest.setDiscount; Assuming discount rate
String expectedOutput Jack North York ;
assertEqualstoString method failed", expectedOutput, request.toString;xpectedOutput, request.toString;
Providing other tests for more info public void test
RideRequest request new RideRequest Jack North York N ;
RideRequest.setTaxrate; Assuming tax rate
RideRequest.setDiscount; Assuming discount rate
String expectedOutput Jack North York ;
assertEqualstoString method failed", expectedOutput, request.toString;
This is my code i have created getter and increment method to increase its value but seems like its not working. Please provide code in toString method for conter to increse with every JUnit test public static void increment i
tostringcounter;
public static int getToStringCounter
return tostringCounter;
public String toString
RideRequest.increment;
double disAmount ;
double Amount Math.roundridePrice taxrate;
if hasDiscount
disAmount Math.roundAmount discount;
String formattedOutput String.formatdss f f RideRequest.getToStringCounter customerName,rideDetails, Amount, disAmount;
return formattedOutput;
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
