Please send questions to
st10@humboldt.edu .
#include <iostream>
#include "MyNode.h"
#include "equalCost.h"
using namespace std;
int main()
{
MyNode node1;
node1 = MyNode(13, 3.98);
cout << endl;
cout << "CONSTRUCTOR TESTS" << endl;
cout << "should be: 3.98: " << node1.get_cost() << endl;
cout << "should be: 13: " << node1.get_quant() << endl;
if (node1.get_nextPtr() == NULL)
{
cout << "HOORAY! next is properly null!" << endl;
}
else
{
cout << "WHAT!!!!???? next ISN'T null?!?" << endl;
}
MyNode nodeBlah;
cout << endl;
cout << "should be: 0: " << nodeBlah.get_cost() << endl;
cout << "should be: 0: " << nodeBlah.get_quant() << endl;
if (nodeBlah.get_nextPtr() == NULL)
{
cout << "HOORAY! next is properly null!" << endl;
}
else
{
cout << "WHAT!!!!???? next ISN'T null?!?" << endl;
}
cout << endl;
cout << "POINTER-RELATED TESTS " << endl;
MyNodePtr nodePtr;
nodePtr = new MyNode(20, 0.99);
node1.set_nextPtr(nodePtr);
// show that node1 is "linked" to another node
cout << node1.get_nextPtr()->get_cost() << endl;
cout << node1.get_nextPtr()->get_quant() << endl;
cout << endl;
cout << "TESTS OF equalCost" << endl;
MyNode node2(58, 3.98);
cout << "should return 0: " << equalCost(node1, *nodePtr)
<< endl;
cout << "should return 1: " << equalCost(node1, node2)
<< endl;
cout << endl;
cout << "TESTING getQuant " << endl;
MyNode node3(58, 3.98);
cout << "should return 0: " << node1.equalQuant(*nodePtr)
<< endl;
cout << "should return 1: " << node2.equalQuant(node3)
<< endl;
cout << endl;
cout << "TESTING overloaded ops" << endl;
cout << "should return 1: " << ( node2 == node3)
<< endl;
cout << " should return 0: " << (node1 == node2)
<< endl;
MyNode node4;
node4 = node1 + node2;
cout << "node4 info: cost: " << node4.get_cost()
<< " quant: " << node4.get_quant() << endl;
return 0;
}