Programming language is Java***
11.7.1. A Car is a Sports Car if ... After three months of analysis a team of business analysts have decided that a car can be marked with the "sports" tag if it satisfies all of the following requirements: it is red, it was manufactured by Ferrari, its engine has more than 6 cylinders. Based on these detailed requirements a team of top-notch developers have come up with the following implementation of the CarSearch class: Listing 11.14. CarSearch class implementation public class CarSearch { private List
cars = new ArrayList(); public void addCar (Car car) { cars.add (car); public List findSportCars() { List sport Cars = new ArrayList(); for (Car car : cars) { if (car.getEngine ().getNbofCylinders() > 6 && Color. RED == car.getColor() && "Ferrari".equals (car.getManufacturer().getName())) { sportcars.add(car); return sport Cars; The Car, Engine and Manufacturer interfaces are presented below: Listing 11.15. Car interface public interface Car { Engine getEngine(); Color getColor(); Manufacturer getManufacturer(); Listing 11.16. Engine interface public interface Engine { int getNbOfCylinders(); Listing 11.17. Manufacturer interface public interface Manufacturer { String getName(); Your task is to write some tests for the findSportCars () method of the CarSearch class. Basically, what you have to do is pass some cars to the CarSearch class (using its addCar()) method, and then verify, whether only sports cars are being returned by the findSportsCars () method. Initially, do this for the original implementation of the CarSearch class. Then, redesign the car interface, so that the CarSearch class does not violate either the "Law of Demeter" or the "Tell, Don't Ask!" principles, and write the tests once again. Compare the amount of work involved in each case. 11.7.1. A Car is a Sports Car if ... After three months of analysis a team of business analysts have decided that a car can be marked with the "sports" tag if it satisfies all of the following requirements: it is red, it was manufactured by Ferrari, its engine has more than 6 cylinders. Based on these detailed requirements a team of top-notch developers have come up with the following implementation of the CarSearch class: Listing 11.14. CarSearch class implementation public class CarSearch { private List cars = new ArrayList(); public void addCar (Car car) { cars.add (car); public List findSportCars() { List sport Cars = new ArrayList(); for (Car car : cars) { if (car.getEngine ().getNbofCylinders() > 6 && Color. RED == car.getColor() && "Ferrari".equals (car.getManufacturer().getName())) { sportcars.add(car); return sport Cars; The Car, Engine and Manufacturer interfaces are presented below: Listing 11.15. Car interface public interface Car { Engine getEngine(); Color getColor(); Manufacturer getManufacturer(); Listing 11.16. Engine interface public interface Engine { int getNbOfCylinders(); Listing 11.17. Manufacturer interface public interface Manufacturer { String getName(); Your task is to write some tests for the findSportCars () method of the CarSearch class. Basically, what you have to do is pass some cars to the CarSearch class (using its addCar()) method, and then verify, whether only sports cars are being returned by the findSportsCars () method. Initially, do this for the original implementation of the CarSearch class. Then, redesign the car interface, so that the CarSearch class does not violate either the "Law of Demeter" or the "Tell, Don't Ask!" principles, and write the tests once again. Compare the amount of work involved in each case