Download the C# project CarVersion3 from the class website. This exercise is only about observing how we can use if-state-ments to implement some business logic. The solution contains a class called Car, in the file Car.cs.
There are three methods in the Car class that use if-statements:
-
- IsEconomic
- IsFamilyCar
- RentalPricePerDay
-
For each of these three methods, make sure you understand what the possible return values are, and under what circumstances each value can be returned.
-
Read the code in InsertCodeHere.cs – it tests the Car class. Before running the program, try to predict the outcome.
-
Run the program, and check that the outcome is as you predicted. If not, you may need to read the Car class code again
-
Try to change some of the values used when creating the three Car objects, and see if you can predict the outcome of running the program