Skip to content

Commit

Permalink
added function to compare the distance between two roads
Browse files Browse the repository at this point in the history
  • Loading branch information
elijahbigk77 committed Apr 23, 2022
1 parent 396eb19 commit c37c572
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
Binary file modified project5
Binary file not shown.
1 change: 1 addition & 0 deletions project5.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ int main(int argc, char *argv[]) {
std::cout << "------------------------------------------------" << std::endl;
std::cout << std::endl;




}
Expand Down
8 changes: 8 additions & 0 deletions province.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,12 @@ void Province::printShortestPath(std::ostream & output) const {
}
}

/**
* < operator used to compare two roads
* @param road2 A road
* @return True if road1 is shorter in length than road 2
*/
bool Province::Road::operator < (Road road2) const {
return this->_length < road2._length;
}

17 changes: 17 additions & 0 deletions test-data/project5.out
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ The shortest routes from Salem are:
------------------------------------------------
------------------------------------------------

The road upgrading goal can be achieved at minimal cost by upgrading:

Salem to Beverly
Danvers to Beverly
Wenham to Danvers
Salem to Lynn

------------------------------------------------
------------------------------------------------


------------------------------------------------
---------------- New DataSet: ------------------
Expand All @@ -65,3 +75,10 @@ The shortest routes from Wenham are:
------------------------------------------------
------------------------------------------------

The road upgrading goal can be achieved at minimal cost by upgrading:

Hamilton to Wenham

------------------------------------------------
------------------------------------------------

0 comments on commit c37c572

Please sign in to comment.