Skip to content

Commit 1ac3c5a

Browse files
committed
uniformed street values with vehicle
1 parent 3b9b696 commit 1ac3c5a

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

docs/Street_8hpp_source.html

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,21 +141,21 @@
141141
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160; </div>
142142
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160;<span class="preprocessor">#endif</span></div>
143143
<div class="ttc" id="aclassStreet_html"><div class="ttname"><a href="classStreet.html">Street</a></div><div class="ttdoc">Street class.</div><div class="ttdef"><b>Definition:</b> Street.hpp:14</div></div>
144-
<div class="ttc" id="aclassStreet_html_a0a02776f5ec50181653f601f5734cef3"><div class="ttname"><a href="classStreet.html#a0a02776f5ec50181653f601f5734cef3">Street::setNLanes</a></div><div class="ttdeci">void setNLanes(int)</div><div class="ttdoc">Set the number of lanes.</div><div class="ttdef"><b>Definition:</b> Street.cpp:59</div></div>
145-
<div class="ttc" id="aclassStreet_html_a0c166cf2e397571bece279d86bb26fd9"><div class="ttname"><a href="classStreet.html#a0c166cf2e397571bece279d86bb26fd9">Street::getVehicleDensity</a></div><div class="ttdeci">double getVehicleDensity() const noexcept</div><div class="ttdoc">get instant vehicle density for the stree</div><div class="ttdef"><b>Definition:</b> Street.cpp:99</div></div>
146-
<div class="ttc" id="aclassStreet_html_a22c7ea3d9fffa9690106e686e3ce029d"><div class="ttname"><a href="classStreet.html#a22c7ea3d9fffa9690106e686e3ce029d">Street::addVehicle</a></div><div class="ttdeci">void addVehicle(std::shared_ptr&lt; Vehicle &gt;)</div><div class="ttdoc">add a vehicle to the street</div><div class="ttdef"><b>Definition:</b> Street.cpp:105</div></div>
147-
<div class="ttc" id="aclassStreet_html_a2cd18c887ffddc3f339208cbd48a7341"><div class="ttname"><a href="classStreet.html#a2cd18c887ffddc3f339208cbd48a7341">Street::getNVehicles</a></div><div class="ttdeci">int getNVehicles() const noexcept</div><div class="ttdoc">Get the number of vehicles on the street.</div><div class="ttdef"><b>Definition:</b> Street.cpp:67</div></div>
148-
<div class="ttc" id="aclassStreet_html_a31893df9143712fbd50b105a022ec20e"><div class="ttname"><a href="classStreet.html#a31893df9143712fbd50b105a022ec20e">Street::Street</a></div><div class="ttdeci">Street(int, int, double, int)</div><div class="ttdoc">Create a new Street object.</div><div class="ttdef"><b>Definition:</b> Street.cpp:16</div></div>
149-
<div class="ttc" id="aclassStreet_html_a3d46d9af33caa59f1e25518624d5be52"><div class="ttname"><a href="classStreet.html#a3d46d9af33caa59f1e25518624d5be52">Street::getInputVelocity</a></div><div class="ttdeci">double getInputVelocity() const noexcept</div><div class="ttdoc">get instant input velocity for the street</div><div class="ttdef"><b>Definition:</b> Street.cpp:85</div></div>
150-
<div class="ttc" id="aclassStreet_html_a450c27afc9fd0f6b46b25d929aa5a65e"><div class="ttname"><a href="classStreet.html#a450c27afc9fd0f6b46b25d929aa5a65e">Street::getIndex</a></div><div class="ttdeci">int getIndex() const noexcept</div><div class="ttdoc">Get the index of the street.</div><div class="ttdef"><b>Definition:</b> Street.cpp:47</div></div>
151-
<div class="ttc" id="aclassStreet_html_a9a399a3194d078eaa0cffc8a100f5bb1"><div class="ttname"><a href="classStreet.html#a9a399a3194d078eaa0cffc8a100f5bb1">Street::getVMax</a></div><div class="ttdeci">double getVMax() const noexcept</div><div class="ttdoc">Get the maximum velocity.</div><div class="ttdef"><b>Definition:</b> Street.cpp:92</div></div>
152-
<div class="ttc" id="aclassStreet_html_aaa70bfead0e982578aed7058b3010115"><div class="ttname"><a href="classStreet.html#aaa70bfead0e982578aed7058b3010115">Street::isFull</a></div><div class="ttdeci">bool isFull() const noexcept</div><div class="ttdoc">Tells if the street is full.</div><div class="ttdef"><b>Definition:</b> Street.cpp:53</div></div>
153-
<div class="ttc" id="aclassStreet_html_aaba4ece5616a59881bcfffa4e6eeb1c4"><div class="ttname"><a href="classStreet.html#aaba4ece5616a59881bcfffa4e6eeb1c4">Street::getDensity</a></div><div class="ttdeci">double getDensity() const noexcept</div><div class="ttdoc">get instant density for the street (in percentage)</div><div class="ttdef"><b>Definition:</b> Street.cpp:94</div></div>
154-
<div class="ttc" id="aclassStreet_html_ab7a0866bc86708c7c5b5918958404b19"><div class="ttname"><a href="classStreet.html#ab7a0866bc86708c7c5b5918958404b19">Street::getLength</a></div><div class="ttdeci">double getLength() const noexcept</div><div class="ttdoc">Get the length of the street.</div><div class="ttdef"><b>Definition:</b> Street.cpp:50</div></div>
155-
<div class="ttc" id="aclassStreet_html_abe49b4d7450640c3f83c55fc682a86fd"><div class="ttname"><a href="classStreet.html#abe49b4d7450640c3f83c55fc682a86fd">Street::setVMax</a></div><div class="ttdeci">void setVMax(double)</div><div class="ttdoc">Set the maximum velocity.</div><div class="ttdef"><b>Definition:</b> Street.cpp:71</div></div>
156-
<div class="ttc" id="aclassStreet_html_ac3ff4ad461cdde617571778827fdd906"><div class="ttname"><a href="classStreet.html#ac3ff4ad461cdde617571778827fdd906">Street::remVehicle</a></div><div class="ttdeci">void remVehicle()</div><div class="ttdoc">remove a vehicle from the street</div><div class="ttdef"><b>Definition:</b> Street.cpp:115</div></div>
157-
<div class="ttc" id="aclassStreet_html_adbcda4d948fa0ed62cdf60d8f20ddc5a"><div class="ttname"><a href="classStreet.html#adbcda4d948fa0ed62cdf60d8f20ddc5a">Street::getOrigin</a></div><div class="ttdeci">int getOrigin() const noexcept</div><div class="ttdoc">Get the origin node index.</div><div class="ttdef"><b>Definition:</b> Street.cpp:41</div></div>
158-
<div class="ttc" id="aclassStreet_html_ae52572b6d133b0ae3441b9ced19ab982"><div class="ttname"><a href="classStreet.html#ae52572b6d133b0ae3441b9ced19ab982">Street::getDestination</a></div><div class="ttdeci">int getDestination() const noexcept</div><div class="ttdoc">Get the destination node index.</div><div class="ttdef"><b>Definition:</b> Street.cpp:44</div></div>
144+
<div class="ttc" id="aclassStreet_html_a0a02776f5ec50181653f601f5734cef3"><div class="ttname"><a href="classStreet.html#a0a02776f5ec50181653f601f5734cef3">Street::setNLanes</a></div><div class="ttdeci">void setNLanes(int)</div><div class="ttdoc">Set the number of lanes.</div><div class="ttdef"><b>Definition:</b> Street.cpp:68</div></div>
145+
<div class="ttc" id="aclassStreet_html_a0c166cf2e397571bece279d86bb26fd9"><div class="ttname"><a href="classStreet.html#a0c166cf2e397571bece279d86bb26fd9">Street::getVehicleDensity</a></div><div class="ttdeci">double getVehicleDensity() const noexcept</div><div class="ttdoc">get instant vehicle density for the stree</div><div class="ttdef"><b>Definition:</b> Street.cpp:108</div></div>
146+
<div class="ttc" id="aclassStreet_html_a22c7ea3d9fffa9690106e686e3ce029d"><div class="ttname"><a href="classStreet.html#a22c7ea3d9fffa9690106e686e3ce029d">Street::addVehicle</a></div><div class="ttdeci">void addVehicle(std::shared_ptr&lt; Vehicle &gt;)</div><div class="ttdoc">add a vehicle to the street</div><div class="ttdef"><b>Definition:</b> Street.cpp:114</div></div>
147+
<div class="ttc" id="aclassStreet_html_a2cd18c887ffddc3f339208cbd48a7341"><div class="ttname"><a href="classStreet.html#a2cd18c887ffddc3f339208cbd48a7341">Street::getNVehicles</a></div><div class="ttdeci">int getNVehicles() const noexcept</div><div class="ttdoc">Get the number of vehicles on the street.</div><div class="ttdef"><b>Definition:</b> Street.cpp:76</div></div>
148+
<div class="ttc" id="aclassStreet_html_a31893df9143712fbd50b105a022ec20e"><div class="ttname"><a href="classStreet.html#a31893df9143712fbd50b105a022ec20e">Street::Street</a></div><div class="ttdeci">Street(int, int, double, int)</div><div class="ttdoc">Create a new Street object.</div><div class="ttdef"><b>Definition:</b> Street.cpp:15</div></div>
149+
<div class="ttc" id="aclassStreet_html_a3d46d9af33caa59f1e25518624d5be52"><div class="ttname"><a href="classStreet.html#a3d46d9af33caa59f1e25518624d5be52">Street::getInputVelocity</a></div><div class="ttdeci">double getInputVelocity() const noexcept</div><div class="ttdoc">get instant input velocity for the street</div><div class="ttdef"><b>Definition:</b> Street.cpp:94</div></div>
150+
<div class="ttc" id="aclassStreet_html_a450c27afc9fd0f6b46b25d929aa5a65e"><div class="ttname"><a href="classStreet.html#a450c27afc9fd0f6b46b25d929aa5a65e">Street::getIndex</a></div><div class="ttdeci">int getIndex() const noexcept</div><div class="ttdoc">Get the index of the street.</div><div class="ttdef"><b>Definition:</b> Street.cpp:56</div></div>
151+
<div class="ttc" id="aclassStreet_html_a9a399a3194d078eaa0cffc8a100f5bb1"><div class="ttname"><a href="classStreet.html#a9a399a3194d078eaa0cffc8a100f5bb1">Street::getVMax</a></div><div class="ttdeci">double getVMax() const noexcept</div><div class="ttdoc">Get the maximum velocity.</div><div class="ttdef"><b>Definition:</b> Street.cpp:101</div></div>
152+
<div class="ttc" id="aclassStreet_html_aaa70bfead0e982578aed7058b3010115"><div class="ttname"><a href="classStreet.html#aaa70bfead0e982578aed7058b3010115">Street::isFull</a></div><div class="ttdeci">bool isFull() const noexcept</div><div class="ttdoc">Tells if the street is full.</div><div class="ttdef"><b>Definition:</b> Street.cpp:62</div></div>
153+
<div class="ttc" id="aclassStreet_html_aaba4ece5616a59881bcfffa4e6eeb1c4"><div class="ttname"><a href="classStreet.html#aaba4ece5616a59881bcfffa4e6eeb1c4">Street::getDensity</a></div><div class="ttdeci">double getDensity() const noexcept</div><div class="ttdoc">get instant density for the street (in percentage)</div><div class="ttdef"><b>Definition:</b> Street.cpp:103</div></div>
154+
<div class="ttc" id="aclassStreet_html_ab7a0866bc86708c7c5b5918958404b19"><div class="ttname"><a href="classStreet.html#ab7a0866bc86708c7c5b5918958404b19">Street::getLength</a></div><div class="ttdeci">double getLength() const noexcept</div><div class="ttdoc">Get the length of the street.</div><div class="ttdef"><b>Definition:</b> Street.cpp:59</div></div>
155+
<div class="ttc" id="aclassStreet_html_abe49b4d7450640c3f83c55fc682a86fd"><div class="ttname"><a href="classStreet.html#abe49b4d7450640c3f83c55fc682a86fd">Street::setVMax</a></div><div class="ttdeci">void setVMax(double)</div><div class="ttdoc">Set the maximum velocity.</div><div class="ttdef"><b>Definition:</b> Street.cpp:80</div></div>
156+
<div class="ttc" id="aclassStreet_html_ac3ff4ad461cdde617571778827fdd906"><div class="ttname"><a href="classStreet.html#ac3ff4ad461cdde617571778827fdd906">Street::remVehicle</a></div><div class="ttdeci">void remVehicle()</div><div class="ttdoc">remove a vehicle from the street</div><div class="ttdef"><b>Definition:</b> Street.cpp:124</div></div>
157+
<div class="ttc" id="aclassStreet_html_adbcda4d948fa0ed62cdf60d8f20ddc5a"><div class="ttname"><a href="classStreet.html#adbcda4d948fa0ed62cdf60d8f20ddc5a">Street::getOrigin</a></div><div class="ttdeci">int getOrigin() const noexcept</div><div class="ttdoc">Get the origin node index.</div><div class="ttdef"><b>Definition:</b> Street.cpp:50</div></div>
158+
<div class="ttc" id="aclassStreet_html_ae52572b6d133b0ae3441b9ced19ab982"><div class="ttname"><a href="classStreet.html#ae52572b6d133b0ae3441b9ced19ab982">Street::getDestination</a></div><div class="ttdeci">int getDestination() const noexcept</div><div class="ttdoc">Get the destination node index.</div><div class="ttdef"><b>Definition:</b> Street.cpp:53</div></div>
159159
</div><!-- fragment --></div><!-- contents -->
160160
</div><!-- doc-content -->
161161
<!-- start footer part -->

docs/classStreet.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ <h2 class="memtitle"><span class="permalink"><a href="#a31893df9143712fbd50b105a
207207
</dl>
208208
<dl class="exception"><dt>Exceptions</dt><dd>
209209
<table class="exception">
210-
<tr><td class="paramname">std::invalid_argument</td><td>If the length is not positive or if the index is negative. </td></tr>
210+
<tr><td class="paramname">std::invalid_argument</td><td>If at least one of the parameters is negative. </td></tr>
211211
</table>
212212
</dd>
213213
</dl>

src/Street.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,18 @@ double Street::_vMin = 75e-2;
1111
/// @param dst The destination node.
1212
/// @param length The length of the street.
1313
/// @param index The index of the street.
14-
/// @throw std::invalid_argument If the length is not positive or if the index
15-
/// is negative.
14+
/// @throw std::invalid_argument If at least one of the parameters is negative.
1615
Street::Street(int src, int dst, double length, int index) {
16+
if (src < 0) {
17+
std::string msg = "Street.cpp:" + std::to_string(__LINE__) + '\t' +
18+
"Street source must be positive.\n";
19+
throw std::invalid_argument(msg);
20+
}
21+
if (dst < 0) {
22+
std::string msg = "Street.cpp:" + std::to_string(__LINE__) + '\t' +
23+
"Street destination must be positive.\n";
24+
throw std::invalid_argument(msg);
25+
}
1726
if (!(length > 0)) {
1827
std::string msg = "Street.cpp:" + std::to_string(__LINE__) + '\t' +
1928
"Street length must be positive.\n";

0 commit comments

Comments
 (0)