Skip to content

Commit

Permalink
late night progress - jake
Browse files Browse the repository at this point in the history
  • Loading branch information
jakedcolbert committed Apr 15, 2022
1 parent a834494 commit 25ac75a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Author: Elijah Opoku-Nyarko and Jake Colbert

# default target
all: project4
all: project5

# compile the code into an executable called 'project1' using C++ 2011
project4: project4.cc
g++ -std=c++11 -o project4 project4.cc
project5: project5.cc province.h
g++ -std=c++11 -o project5 project5.cc

# test the code against an expected output file
# this test should grow into a spaceship and end with blinkers
test-nowhere:
./project4 < test-files/t01-nowhere.in > tests/project4.out
./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
Binary file added project5
Binary file not shown.
6 changes: 4 additions & 2 deletions project5.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@

using namespace std;


int main() {
while(!cin.eof()) {
Province province(cin);
cout << "its not actually running" << endl;
// the following lines produce 'undefined symbols for architecture' errors
// Province theProvince = * new Province(cin);
// theProvince.printAll(cout);
}
}

18 changes: 11 additions & 7 deletions province.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ using namespace std;
* Danvers, not a bridge, 2.9 miles long)
*/

Province::Province(std::istream &source) {
Province::Province(std::istream & source) {
// Read first line of input
source >> _numberOfTowns >> _numberOfRoads;
_towns = new Town[_numberOfTowns];
std::map<std::string, int> townMap; // maps town names to their indexes in _towns

// Read town names
for (int i = 0; i < _numberOfTowns; i++) {
source >> _towns.push_back(Town()); // This needs to be converted to vector, im not sure how exactly
source >> _towns[i]._name; // This needs to be converted to vector, im not sure how exactly
townMap[_towns[i]._name] = i;
}

Expand All @@ -44,14 +45,17 @@ Province::Province(std::istream &source) {
}
}

void Province::printAll(int start, std::ostream & output) const{
void Province::printAll(std::ostream & output) {
output << "The input data is:" << endl << endl;

for (Town town : _towns) {
for (int i = 0; i < sizeof(_towns)/sizeof(_towns[0]); i++) {
output << _towns[i]._name << endl;
for (Road road : _towns[i]._roads) {
output << "\t" << endl; // needs to be finished too
output << "\t" << road._tail << " " << road._length << " mi";
if (road._isBridge == 'B' || 'b') {
output << " via bridge" << endl;
} else {
output << endl;
}
}

}
}
6 changes: 2 additions & 4 deletions province.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ class Province

/**
* Print towns and roads in province in breadth-first search order
* @param start Index to start traversal at
* @param output Stream to print data to
*/
void printAll(int start, std::ostream & output) const;

void printAll(std::ostream & output);
void printShortestPath(std::ostream & output) const;

/**
Expand Down Expand Up @@ -100,6 +98,6 @@ class Province

int _numberOfTowns;
int _numberOfRoads;
std::vector<Town> _towns;
Town *_towns;
std::vector<Road> _roads;
};

0 comments on commit 25ac75a

Please sign in to comment.