Car.hpp 928 Bytes
Newer Older
Martin Kröning's avatar
Martin Kröning committed
1 2 3 4
#pragma once

#include "Vehicle.hpp"
#include <string>
5
#include <string_view>
6
class MapAppAPIWrapper;
Martin Kröning's avatar
Martin Kröning committed
7 8 9 10

class Car : public Vehicle {
public:
  /// The fuel tank is half full at construction
11 12
  Car(std::string name, double topSpeed, double timeOfStart,
      double fuelConsumption, double fuelCapacity, double time);
Martin Kröning's avatar
Martin Kröning committed
13

14
  void draw(MapAppAPIWrapper &mapApp, std::string_view laneName,
Martin Kröning's avatar
Martin Kröning committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
            double laneLength, double speedLimit) const override;

  double getSpeed(double speedLimit) const override;

  void process(double time, double maximumDistanceOnLane,
               double speedLimit) override;

  /// Refuels the vehicle provided the \p availableFuel in l
  /// \returns The amount of fuel in l that has been taken
  double refuel(double availableFuel);

private:
  /// Fuel consumption in l/100km
  double fuelConsumption;

  /// Fuel capacity in l
  double fuelCapacity;

  /// Remaining fuel in l
  double fuel;
};