Easy_rider
 
Loading...
Searching...
No Matches
Road Class Reference

Represents a road connecting two Intersections in 2D space, with a computed length and a maximum speed. More...

#include <Road.h>

Public Member Functions

 Road ()
 Default constructor. Initializes both endpoints at (0,0), length to 0.0, and maxSpeed to 0.
 
 Road (const Intersection &from, const Intersection &to, int maxSpeed)
 Parameterized constructor.
 
Intersection getFrom () const
 Retrieves the starting Intersection.
 
Intersection getTo () const
 Retrieves the ending Intersection.
 
double getLength () const
 Retrieves the computed length of the road.
 
int getMaxSpeed () const
 Retrieves the maximum speed for this road.
 

Detailed Description

Represents a road connecting two Intersections in 2D space, with a computed length and a maximum speed.

Constructor & Destructor Documentation

◆ Road()

Road::Road ( const Intersection from,
const Intersection to,
int  maxSpeed 
)

Parameterized constructor.

Parameters
fromThe starting Intersection.
toThe ending Intersection.
maxSpeedThe maximum allowed speed on this road.

Automatically computes the Euclidean length between from and to.

Member Function Documentation

◆ getFrom()

Intersection Road::getFrom ( ) const

Retrieves the starting Intersection.

Returns
A copy of the 'from' Intersection.

◆ getLength()

double Road::getLength ( ) const

Retrieves the computed length of the road.

Returns
The Euclidean distance between 'from' and 'to'.

◆ getMaxSpeed()

int Road::getMaxSpeed ( ) const

Retrieves the maximum speed for this road.

Returns
The maximum speed (int).

◆ getTo()

Intersection Road::getTo ( ) const

Retrieves the ending Intersection.

Returns
A copy of the 'to' Intersection.

The documentation for this class was generated from the following files: