Question: Class TrainTest import java.util.ArrayList; /** * The test class TrainTest. * */ public class TrainTest extends junit.framework.TestCase { /** * Default constructor for test class

Class TrainTest
import java.util.ArrayList;
/** * The test class TrainTest. * */ public class TrainTest extends junit.framework.TestCase { /** * Default constructor for test class TrainTest */ public TrainTest() { }
/** * Sets up the test fixture. * * Called before every test case method. */ protected void setUp() { }
/** * Tears down the test fixture. * * Called after every test case method. */ protected void tearDown() { } public void testCreateEmptyTrain() { Train aTrain = new Train(); /* Verify that a new train has no cars. */ assertEquals(0, aTrain.cars().size()); } public void testAddCar() { Train aTrain = new Train(); Car car1 = new Car(1250, true); aTrain.addCar(car1); Car car2 = new Car(1300, false); aTrain.addCar(car2); Car car3 = new Car(1740, false); aTrain.addCar(car3); ArrayList
Class Train
import java.util.ArrayList;
public class Train { /** The cars in this train. */ private ArrayList
Part 3: Improving Class TrainTest 1. Modify testAddCar): o Add a fourth car (a business class car) to testAddCar() and ensure that it functions properly. o Rewrite the code to remove the variable "aCar" as it is not needed. 2. Modify testlssueTicket() so that it also uses a fourth car: o Business seat booking: Fill all the seats in both business cars (instead of just one As before, check that another business seat cannot be booked. Check that all seats in the 2nd business car are also booked. o Economy seat booking At the end of the test check that the second business car seats are still all booked. o Now rewrite the code so that you can remove the boolean "result" as it's not 3.Modify testCancelTicket so that it also uses a fourth car: o Create a train with four cars (two business and two economy) as in the previous methods o Fill the seats in the first business car and half the second business car, but just one of the economy cars. o In addition to the other existing checks: cancel one of the booked seats near the front half of the second business car and ensure that functions properly, and attempt to cancel one of the unbooked seats near the back of the second business car and ensure that functions correctly o Now rewrite the code so that you can remove the boolean "result" as it's not needed. Part 3: Improving Class TrainTest 1. Modify testAddCar): o Add a fourth car (a business class car) to testAddCar() and ensure that it functions properly. o Rewrite the code to remove the variable "aCar" as it is not needed. 2. Modify testlssueTicket() so that it also uses a fourth car: o Business seat booking: Fill all the seats in both business cars (instead of just one As before, check that another business seat cannot be booked. Check that all seats in the 2nd business car are also booked. o Economy seat booking At the end of the test check that the second business car seats are still all booked. o Now rewrite the code so that you can remove the boolean "result" as it's not 3.Modify testCancelTicket so that it also uses a fourth car: o Create a train with four cars (two business and two economy) as in the previous methods o Fill the seats in the first business car and half the second business car, but just one of the economy cars. o In addition to the other existing checks: cancel one of the booked seats near the front half of the second business car and ensure that functions properly, and attempt to cancel one of the unbooked seats near the back of the second business car and ensure that functions correctly o Now rewrite the code so that you can remove the boolean "result" as it's not needed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
