Write a class called SportsCar containing the two instance variables maxSpeed and horsepower of type int. Both these instance variables must, in any SportsCar object, hold values that are greater than certain pre-specified values; otherwise, they do not qualify as proper SportsCar objects. In our case, the minimum value for maxSpeed is 200 kilometers/hour, and the minimum value for horsepower is 250 hp. Include suitable member variables in the SportsCar class to hold these values (called maxSpeedRequirement and horsepowerRequirement) and write a method called SportsCheck that returns true if both of the maxSpeed and horsepower for a particular SportsCar object are above the minimum requirements; otherwise, false. Write accessor and mutator methods for maxSpeed, horsepower, maxSpeedRequirement, and horsepowerRequirement.
Include another class containing a Main method to demonstrate the SportsCar class.
Please keep this program available for exercise 2.
Each object instantiated from the SportsCar class you wrote in exercise 1 can only be driven by certain people. Include a method in the SportsCar class that will read in any number of driver names (first names); call it SetLegalDrivers. So, if you have a SportsCar object in your program called sportsCar1, you can set the legal drivers by, for example, the following call:
sportsCar1.SetLegalDrivers("Tom", "Julie", "Teddy", "Mary")
or the call
Write a method called DriverCheck that lets you provide a first name as an argument and then returns true if the driver is allowed to drive the SportsCar object; otherwise, it returns false.
Please keep this program handy for exercise 3.
Add a static method called GetMinimumRequirements containing two ref parameters of type int called newMaxSpeed and newHorsepower. This should allow other objects of other classes to call this method and obtain the values of both maxSpeed and horsepower held by the SportsCar class with just one method call. Write a tester class called Calculator with a static method called NumberCruncher that makes a call to GetMinimumRequirements and simply prints out the two values obtained from this call.
Keep the source code intact for the exercise 4.
Equip the SportsCar class with an instance method called MostPowerful that has one formal parameter of type SportsCar called carCompare. Enable the MostPoweful method to compare the SportsCar, referenced by the formal parameter carCompare, with the SportsCar object the MostPowerful method is called for. The most powerful SportsCar object contains the greater horsepower instance variable. Return from the method a reference to the most powerful object.
Allow not only one SportsCar to be passed as an argument to the MostPowerful method, but also two SportsCar objects. In case two arguments of type SportsCar are passed to MostPowerful, three objects are compared and the most powerful SportsCar object returned (hint: use method overloading to implement this functionality).