Untitled
unknown
plain_text
2 years ago
1.6 kB
8
Indexable
Never
Node_T* ReadAVLTree(string filename, int luachon) { Node_T* pRoot; Init(pRoot); ifstream ifs(filename); if (!ifs.is_open()) { cout << "\ncannot open file"; return NULL; } string temp = ""; getline(ifs, temp); while (!ifs.eof()) { Card c; getline(ifs, c.id, ';'); getline(ifs, c.name, ';'); getline(ifs, c.set, ';'); getline(ifs, c.type, ';'); getline(ifs, temp, ';'); if (strcmp(temp.c_str(), "True") == 0) { c.collectible = true; } else if (strcmp(temp.c_str(), "False") == 0) { c.collectible = false; } getline(ifs, temp, ';'); c.mana = atoi(temp.c_str()); getline(ifs, temp, ';'); c.attack = atoi(temp.c_str()); getline(ifs, temp, ';'); c.health = atoi(temp.c_str()); getline(ifs, temp, '\n'); c.armor = atoi(temp.c_str()); cout << c.id << " " << c.name << " " << c.set << " " << c.type << " "; if (c.collectible == true) { cout << "True "; } else { cout << "False "; } cout << c.mana << " " << c.attack << " " << c.health << " " << c.armor << endl; //Node_T* p = CreatNode_T(c); //if (luachon == 1) // lựa chọn số 1: duyệt theo ID //{ // Insert_ID(pRoot, p); //} //else if (luachon == 2) // lựa chọn số 2: duyệt theo Mana->Health->ID //{ // Insert_Mana_Health_ID(pRoot, p); //} //else // lựa chọn số 3: duyệt theo attack + health → mana → ID. //{ // Insert_HealthAttack_Mana_ID(pRoot, p); //} } ifs.close(); return pRoot; }