Skip to content

Commit

Permalink
moved output operator for Connection to node.cpp so we can print Coord
Browse files Browse the repository at this point in the history
  • Loading branch information
floft committed May 26, 2013
1 parent 1e899f6 commit 3da5c2f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
5 changes: 5 additions & 0 deletions headers/node.h
Expand Up @@ -50,6 +50,7 @@ class Node
~Node();
friend class Game;
friend ostream& operator<<(ostream&, const Game&);
friend ostream& operator<<(ostream&, const Connection&);
private:
void updateOpen(); // update open array after adding a connection
};
Expand All @@ -59,4 +60,8 @@ enum Dir
Up=0, Right, Down, Left
};

// This is here since we want to print out the coordinate of the Node
// which requires that the class has been declared.
ostream& operator<<(ostream&,const Connection&);

#endif
1 change: 0 additions & 1 deletion headers/structs.h
Expand Up @@ -42,6 +42,5 @@ struct Connection

ostream& operator<<(ostream&,const Coord&);
ostream& operator<<(ostream&,const Line&);
ostream& operator<<(ostream&,const Connection&);

#endif
14 changes: 11 additions & 3 deletions node.cpp
@@ -1,6 +1,3 @@
/*
* These implications likely are not complete
*/
#include "headers/node.h"

Node::Node(Coord point, Connection con1, Connection con2)
Expand Down Expand Up @@ -168,3 +165,14 @@ Node::~Node()
{

}

ostream& operator<<(ostream& os, const Connection& con)
{
if (con.exists())
os << "Node " << con.dest << " @ " << con.dest->loci
<< " via " << con.line << ":{ " << *con.line << " }";
else
os << "default";

return os;
}
10 changes: 0 additions & 10 deletions structs.cpp
Expand Up @@ -6,16 +6,6 @@ ostream& operator<<(ostream& os, const Coord& coord)
return os;
}

ostream& operator<<(ostream& os, const Connection& con)
{
if (con.exists())
os << "Node " << con.dest << " via " << con.line << ":{ " << *con.line << " }";
else
os << "default";

return os;
}

ostream& operator<<(ostream& os, const Line& line)
{
for (int i = 0; i < line.size(); i++)
Expand Down

0 comments on commit 3da5c2f

Please sign in to comment.