Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/yeremyacuna/LYNX/llms.txt

Use this file to discover all available pages before exploring further.

A Driver is a service provider in the LYNX platform who is paired with a registered vehicle. Drivers authenticate with their DNI and password, then access a dedicated menu to register trips, view their completed-trip history, manage availability, and monitor earnings. Driver records are stored in memory and persisted to assets/drivers.txt between sessions.

Driver Profile

Every Driver record contains the following fields, sourced directly from Driver.h:
FieldTypeDescriptionDefault
driverIdstringAuto-generated identifier in the format DRV-XXXX (4 digits)Generated on registration
namestringFull display name of the driver
dnistring8-digit national identity number used as the login key
passwordstringLogin credential
ratingfloatDriver rating, updated by passengers after each trip5.0
isAvailableboolWhether the driver can currently accept new tripstrue
totalTripsintCumulative number of completed trips0
totalEarningsfloatGross cumulative earnings across all completed trips0.0
vehicleVehicleThe vehicle associated with this driver
The static helper Driver::syncNextDriverId(int nextId) re-synchronises the internal ID counter after loading persisted data, ensuring DRV-XXXX codes remain sequential across restarts.

Vehicle

Each Driver has exactly one associated Vehicle. The Vehicle class (defined in Vehicle.h) carries five fields:
FieldTypeDescription
platestringVehicle licence plate (e.g. EQH-692)
brandstringManufacturer (e.g. BMW, Toyota)
modelstringModel name (e.g. Serie 1, Corolla)
colorstringExterior colour
yearintModel year
The Vehicle class exposes two plate getters: getPlate() (non-const, for general access) and getPlates() (const, for read-only contexts such as sorted container keys and const method calls).

Driver Registration

Drivers register themselves directly from the driver entry menu, following the same self-service flow used by passengers. The system prompts for driver details and vehicle information before creating the account.
1

Open the Driver entry screen

At the main menu, select “Soy conductor” and then choose “Registrarme”.
2

Enter driver details

Provide your full name, 8-digit DNI, and a password. The system validates the DNI length via AuthManager::validateDni(DNI).
3

Enter vehicle details

Supply the vehicle’s plate, brand, model, colour, and year. The year must be within the accepted range (2005–2026 in the console flow).
4

Account is created

AuthManager::registerDriver(name, DNI, password, vehicle) constructs a Driver object with an auto-generated DRV-XXXX identifier, initialises rating to 5.0, isAvailable to true, and both totalEarnings and totalTrips to zero. The record is saved to assets/drivers.txt.

Driver Menu Actions

After logging in with their DNI and password, the following actions are available, as defined in MainMenu.h:
  • Registrar Viaje Manual — the driver logs a completed trip by entering origin, destination, distance (km), and fare tier. The system creates a Trip with status "completado" and pushes it directly onto the history stack. Driver::acceptRide(price) increments totalTrips and totalEarnings and sets isAvailable = false; Driver::finishRide() immediately sets isAvailable = true.
  • Ver Carreras Hechas — displays the driver’s trip history, filtered from the global history stack by the driver’s DNI.
  • Cambiar a Disponible / Finalizar Viaje — if the driver has an active trip, this action calls TripManager::finishTrip(tripId, authManager) and marks the driver available. If no active trip exists, availability is set to true directly via AuthManager::setDriverAvailability(dni, true).
  • Ver mis Ganancias — shows gross earnings, platform commission (20 %), and net earnings. The net value is computed by the lambda inside Driver::getNetEarnings():
// From Driver.h
float getNetEarnings() {
    auto calcularNeto = [](float bruto) -> float {
        return bruto * 0.80f;
    };
    return calcularNeto(totalEarnings);
}
  • Perfil — displays the driver’s full summary including vehicle details.
  • Cerrar sesion — ends the driver session and returns to the main menu.

Rating System

A driver’s rating starts at 5.0 and is updated each time a passenger rates them. The update formula is a running weighted average implemented in Driver::updateRating(float nuevaCalif):
// From Driver.h
void updateRating(float nuevaCalif) {
    auto calcPromedio = [](float actual, float nueva, int viajes) -> float {
        if (viajes <= 1) return nueva;
        return ((actual * (viajes - 1)) + nueva) / viajes;
    };
    rating = calcPromedio(rating, nuevaCalif, totalTrips);
}
Ratings are persisted via AuthManager::updateDriverRating(dni, newRating). Administrators can sort all drivers by rating using AuthManager::sortDriversByRating() (ShellSort, descending).
TripManager::matchBestDriver(authManager) scans the full driver list and selects the available driver with the highest rating for automatic trip assignment. Keeping your rating high directly increases the probability of being matched first when a passenger requests a ride.

Build docs developers (and LLMs) love