diff --git a/Makefile b/Makefile index da853a5..e778e86 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,12 @@ all: project5 # compile the code into an executable called 'project1' using C++ 2011 -project5: project5.cc province.h - g++ -std=c++11 -o project5 project5.cc +project5: project5.cc province.cc province.h + g++ -std=c++11 -o project5 project5.cc province.cc # test the code against an expected output file # this test should grow into a spaceship and end with blinkers test-nowhere: ./project5 < test-files/t01-nowhere.in > tests/project4.out diff test-files/project4.out test-files/t01-nowhere.out > test.diff - wc -l test.diff + wc -l test.diff diff --git a/project5 b/project5 index 1662a54..5507240 100755 Binary files a/project5 and b/project5 differ diff --git a/project5.cc b/project5.cc index 47f8777..b7b147a 100644 --- a/project5.cc +++ b/project5.cc @@ -20,10 +20,8 @@ using namespace std; int main() { while(!cin.eof()) { - cout << "its not actually running" << endl; - // the following lines produce 'undefined symbols for architecture' errors - // Province theProvince = * new Province(cin); - // theProvince.printAll(cout); + Province theProvince(cin); + theProvince.printAll(cout); } } diff --git a/province.cc b/province.cc index 6f89d3b..20607a2 100644 --- a/province.cc +++ b/province.cc @@ -3,15 +3,16 @@ * Authors: Elijah Opoku-Nyarko and Jake Colbert */ -#include "./province.h" #include #include #include #include +#include "province.h" + using namespace std; -/* +/*f * Constructor * @param source File containing province: * 1. One line: number of towns (n), number of roads (p) @@ -32,14 +33,16 @@ Province::Province(std::istream & source) { // Read town names for (int i = 0; i < _numberOfTowns; i++) { source >> _towns[i]._name; // This needs to be converted to vector, im not sure how exactly + cout << "This is the name: " << &_towns[i]._name << endl; townMap[_towns[i]._name] = i; } for (int i = 0; i < _numberOfRoads; i++) { string head, tail; char bridge; - float distance; + float distance; source >> head >> tail >> bridge >> distance; + cout << "This is the road: " << _towns[townMap.at(head)]._roads << endl; // add a road to the _roads array that belongs to the town at the index map.at(head) returns _towns[townMap.at(head)]._roads.push_back(Road(townMap.at(head), townMap.at(tail), bridge, distance)); } @@ -47,7 +50,8 @@ Province::Province(std::istream & source) { void Province::printAll(std::ostream & output) { output << "The input data is:" << endl << endl; - for (int i = 0; i < sizeof(_towns)/sizeof(_towns[0]); i++) { + cout << endl << "Size of towns: " << sizeof(&_towns)/sizeof(&_towns[0]) << endl; + for (int i = 0; i < sizeof(&_towns)/sizeof(&_towns[0]); i++) { output << _towns[i]._name << endl; for (Road road : _towns[i]._roads) { output << "\t" << road._tail << " " << road._length << " mi";