public void addRelation(Relation newRelation) { if (this.relations == null) { this.relations = new List<Relation>(); } else { //if the object already has this relation if (hasRelation(newRelation)) { return; } } this.relations.Add(newRelation); }
//see if this object has a given relation public bool hasRelation(Relation relation) { foreach (Relation relationTemp in this.relations) { if (relationTemp == relation) { return true; } } return false; }