Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The test code is as follows: /** * Test Suite for UberService class. * * @author Stephan Jamieson * @version 19/7/2016 */ public class TestUberService

image text in transcribed

image text in transcribed

image text in transcribed

The test code is as follows:

/** * Test Suite for UberService class. * * @author Stephan Jamieson * @version 19/7/2016 */ public class TestUberService { private TestUberService() {} public static void main(final String[] args) { // Requirements A, G, H, I, J, K: check setDetails() and observers. // Test 1: Check getName() System.out.println("Test 1"); UberService service = new UberService(); service.setDetails("UberX", 70, 700, 500, 2500); if (service.getName().equals("UberX")) { System.out.println("Pass"); } else { System.out.println("Fail"); } // Test 2: Check getCostPerMinute() System.out.println("Test 2"); service = new UberService(); service.setDetails("UberX", 70, 700, 500, 2500); if (service.getCostPerMinute()==70) { System.out.println("Pass"); } else { System.out.println("Fail"); } // Test 3: Check getCostPerKilometre(). System.out.println("Test 3"); service = new UberService(); service.setDetails("UberX", 70, 700, 500, 2500); if (service.getCostPerKilometre()==700) { System.out.println("Pass"); } else { System.out.println("Fail"); } // Test 4: Check getBaseFare() System.out.println("Test 4"); service = new UberService(); service.setDetails("UberX", 70, 700, 500, 2500); if (service.getBaseFare()==500) { System.out.println("Pass"); } else { System.out.println("Fail"); } // Test 5: Check getCancellationFee() System.out.println("Test 5"); service = new UberService(); service.setDetails("UberX", 70, 700, 500, 2500); if (service.getCancellationFee()==2500) { System.out.println("Pass"); } else { System.out.println("Fail"); } // Requirements L, M, N, O, P: check getMethods do not change anything. // Test 6: Req L, check getName() System.out.println("Test 6"); service = new UberService(); service.setDetails("UberX", 70, 700, 500, 2500); if (service.getName().equals(service.getName()) &&service.getCostPerMinute()==70 &&service.getCostPerKilometre()==700 &&service.getBaseFare()==500 &&service.getCancellationFee()==2500) { System.out.println("Pass"); } else { System.out.println("Fail"); } // Test 7: Req M, check getCostPerMinute() System.out.println("Test 7"); service = new UberService(); service.setDetails("UberXL", 70, 700, 500, 2500); if (service.getCostPerMinute()==service.getCostPerMinute() &&service.getName().equals("UberXL") &&service.getCostPerKilometre()==700 &&service.getBaseFare()==500 &&service.getCancellationFee()==2500) { System.out.println("Pass"); } else { System.out.println("Fail"); } // Test 8: req N, check getCostPerKilometre(). System.out.println("Test 8"); service = new UberService(); service.setDetails("UberXL", 70, 700, 500, 2500); if (service.getCostPerKilometre()==700 &&service.getName().equals("UberXL") &&service.getCostPerMinute()==70 &&service.getBaseFare()==500 &&service.getCancellationFee()==2500) { System.out.println("Pass"); } else { System.out.println("Fail"); } // Test 9: req O check getBaseFare() System.out.println("Test 9"); service = new UberService(); service.setDetails("UberX", 70, 700, 500, 2500); if (service.getBaseFare()==500 &&service.getName().equals("UberX") &&service.getCostPerMinute()==70 &&service.getCostPerKilometre()==700 &&service.getCancellationFee()==2500) { System.out.println("Pass"); } else { System.out.println("Fail"); } // Test 10: req P, check getCancellationFee() System.out.println("Test 10"); service = new UberService(); service.setDetails("UberX", 70, 700, 500, 2500); if (service.getCancellationFee()==2500 &&service.getName().equals("UberX") &&service.getCostPerMinute()==70 &&service.getCostPerKilometre()==700 &&service.getBaseFare()==500) { System.out.println("Pass"); } else { System.out.println("Fail"); } // Requirements B, R: check setName() // Test 11: System.out.println("Test 11"); service = new UberService(); service.setDetails("UberXL", 70, 700, 2000, 2500); service.setName("UberExtraLarge"); if (service.getName().equals("UberExtraLarge") &&service.getCostPerMinute()==70 &&service.getCostPerKilometre()==700 &&service.getBaseFare()==2000 &&service.getCancellationFee()==2500) { System.out.println("Pass"); } else { System.out.println("Fail"); } // Requirements C, S: check setCostPerMinute() // Test 12: System.out.println("Test 12"); service = new UberService(); service.setDetails("UberXL", 70, 700, 2000, 2500); service.setCostPerMinute(17); if (service.getCostPerMinute()==17 &&service.getName().equals("UberXL") &&service.getCostPerKilometre()==700 &&service.getBaseFare()==2000 &&service.getCancellationFee()==2500) { System.out.println("Pass"); } else { System.out.println("Fail"); } // Requirements D, T: check setCostPerKilometre() // Test 13: System.out.println("Test 13"); service = new UberService(); service.setDetails("UberXL", 70, 700, 500, 2500); service.setCostPerKilometre(633); if (service.getCostPerKilometre()==633 &&service.getName().equals("UberXL") &&service.getCostPerMinute()==70 &&service.getBaseFare()==500 &&service.getCancellationFee()==2500) { System.out.println("Pass"); } else { System.out.println("Fail"); } // Requirements E, U: check setBaseFare() // Test 14: System.out.println("Test 14"); service = new UberService(); service.setDetails("UberXL", 70, 700, 2000, 2500); service.setBaseFare(2300); if (service.getBaseFare()==2300 &&service.getName().equals("UberXL") &&service.getCostPerMinute()==70 &&service.getCostPerKilometre()==700 &&service.getCancellationFee()==2500) { System.out.println("Pass"); } else { System.out.println("Fail"); } // Requirements F, V: check setCancellationFee() // Test 15: System.out.println("Test 15"); service = new UberService(); service.setDetails("UberXL", 70, 700, 500, 2500); service.setCancellationFee(2300); if (service.getCancellationFee()==2300 &&service.getName().equals("UberXL") &&service.getCostPerMinute()==70 &&service.getCostPerKilometre()==700 &&service.getBaseFare()==500) { System.out.println("Pass"); } else { System.out.println("Fail"); } // Requirement Q: check calculateFare() // Test 16: System.out.println("Test 16"); service = new UberService(); service.setDetails("UberX", 70, 700, 500, 2500); double EPSILON = 0.0000001; if (Math.abs(service.calculateFare(3.0, 7.0)-5610.0) This question concerns Uber, in particular, (i) writing an UberService class to model an Uber service from the point of view of price, and (i) using a supplied test suite to drive the process. Consider the following specification for an UberService type of object. Class UberService An UberService object represents an Uber service from the point of view of price. (Services differ in characteristics such as luxury and capacity of the vehicle, and consequently, in price.) Each service has a base fare, a cost per minute, cost per kilometre, and cancellation fee. The cost ofa journey consists of the base fare+cost for minutes+ cost for distance. Methods void setDetails(String name, int costPerMin, int costPerKM, int baseFee, int cancellationFee) //Set the details of this service to the given values. void setName(String name) // Set the service name. String getName) /Obtain the service name. void setCostPerMinute(int cents) // Set the cost per minute. int getCostPerMinutel) // Set the cost per minute in cents. void setCostPerKilometre(int cents) // Set the cost per kilometre. int //get the cost per kilometre in cents. void setBaseFare(int cents) // Set the base fare. int getBaseFare() // get the base fare in cents. void setCancellationFee(int n) // Set the cancellation fee. int getCancellationFeel) // Obtain the cancellation fee in cents for this service. double calculateFare double minutes, double distance) //Obtain the fare fin the form of a real number of cents) for a journey of the // given time and distance

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data 29th British National Conference On Databases Bncod 2013 Oxford Uk July 2013 Proceedings Lncs 7968

Authors: Dan Olteanu ,Georg Gottlob ,Christian Schallhart

2013th Edition

3642394663, 978-3642394669

More Books

Students also viewed these Databases questions

Question

What is meant by Career Planning and development ?

Answered: 1 week ago

Question

What are Fringe Benefits ? List out some.

Answered: 1 week ago

Question

1. Identify three approaches to culture.

Answered: 1 week ago

Question

2. Define communication.

Answered: 1 week ago

Question

4. Describe how cultural values influence communication.

Answered: 1 week ago