1.4-Software-Development-Principles

Fueling a car

We are going to build a class and implement methods to simulate the use of a new car. Read through all the requirements before you start building!

Create a car class that includes the following characteristics: brand, license plate, tank size in litres, current tank position, fuel consumption (consumption 16 means 16 km on 1 litre of petrol) and mileage.

Requirements:

For this exercise we intentionally left the class diagram partially open. This means that you can decide what attributes and (helper) methods you might want to add.

Examples for inspiration

Preview

Preview

Preview

Preview

Unittesting

Please not that this exercies copies OOP week 1 exactly. It’s not the point to simply do the assignment again. (Simply copy the code/project from last time.) This time around we need you to write unittests that confirm that the car works as specified in the requirements:

Req.# Description Result
R01 Upon creation car has a legal license plate Untested
R02 Upon creation car has a full tank Untested
R04 When you drive kilometers go up, and fuel goes down. Untested
R05 When the tank is (nearly) empty, the car won’t drive. Untested
R06 When the tank is full, no fuel may be added Untested
R07 When the tank has room you can add some fuel Untested
R08 When you call methods with illegal arguments, the right exception should be thrown. Untested