Skip to content

Commit

Permalink
Fixed unknown errors. Revealed to be problem with makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
jakedcolbert committed Apr 17, 2022
1 parent 25ac75a commit 109973d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file modified project5
Binary file not shown.
6 changes: 2 additions & 4 deletions project5.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

12 changes: 8 additions & 4 deletions province.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
* Authors: Elijah Opoku-Nyarko and Jake Colbert
*/

#include "./province.h"
#include <algorithm>
#include <string>
#include <stack>
#include <cfloat>

#include "province.h"

using namespace std;

/*
/*f
* Constructor
* @param source File containing province:
* 1. One line: number of towns (n), number of roads (p)
Expand All @@ -32,22 +33,25 @@ 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));
}
}

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";
Expand Down

0 comments on commit 109973d

Please sign in to comment.