/// <summary> /// Checks whether the node has all attributes /// </summary> /// <param name="node"> A node </param> /// <returns> If the node has all needed attributes </returns> private static bool hasAttributes(XmlNode node) { bool hasAge = XMLFileIO.hasAge(node); bool hasName = XMLFileIO.hasName(node); bool hasSex = XMLFileIO.hasSex(node); bool hasColor = XMLFileIO.hasColor(node); return(hasAge && hasName && hasSex && hasColor); }
/// <summary> /// Creates a rabbit using the node's attributes and adds it to the hill /// </summary> /// <param name="hill"> A hill </param> /// <param name="node"> A node </param> private static void createRabbit(Hill hill, XmlNode node) { int age = XMLFileIO.readAge(node); string name = XMLFileIO.readName(node); Sex sex = XMLFileIO.readSex(node); Color color = XMLFileIO.readColor(node); addRabbit(hill, new Rabbit(age, sex, color, name)); }
/// <summary> /// Runs the hill /// </summary> public static void runHill() { const string FILE_NAME = "InitialState.xml"; const int NUM_OF_FEMALES = 3; const int NUM_OF_MALES = 2; Hill hill; if (XMLFileIO.doesFileExist(FILE_NAME)) { hill = new Hill(); generateHill(FILE_NAME, hill); } else { hill = new Hill(NUM_OF_MALES, NUM_OF_FEMALES); } automateHill(hill); }
/// <summary> /// Gets all nodes from a file /// </summary> /// <param name="fileName"> The file </param> /// <returns> The child nodes </returns> private static XmlNodeList fileNodes(string fileName) { XmlDocument file = XMLFileIO.loadXMLFile(fileName); return(XMLFileIO.childNodes(file)); }