fixed douplicate functions for getting nodes and topics

This commit is contained in:
Glen Turner
2015-06-19 14:41:28 -07:00
parent 82196e461f
commit d146020719
13 changed files with 361 additions and 308 deletions

View File

@@ -0,0 +1,55 @@
function Topic(name, type)
{
this.name = name;
this.type = type;
this.includeInBag = false;
this.equals = function (otherTopic)
{
if( this.name == otherTopic.name && this.type == otherTopic.type)
{
return true;
}
return false;
};
};
function containsTopic(obj, list) {
var x;
for (x in list) {
if (obj.equals(list[x])) {
return true;
}
}
return false;
}
function testToics()
{
var topics = [new Topic("a","a_t"), new Topic("b","b_t"), new Topic("c","c_t")];
console.log("Testing Topic");
if (containsTopic(new Topic("a","a_t"),topics) == true)
{
console.log("pass")
}
else
{
console.log(" contains true fail")
}
if (containsTopic(new Topic("d","d_t"),topics) == false)
{
console.log("pass")
}
else
{
console.log(" contains d fail")
}
}
testToics();