1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
int main()
{
try
{
Link *gods = new Link{ { "Odin", "Norse", "Eight-legged flying horse called Sleipnir", "Spear called Gungnir" } };
gods = gods->add_ordered(new Link{ { "Thor", "Norse", "Chariot pulled by goats Tanngrisnir and Tanngnjostr",
"Hammer called Mjolnir" } });
gods = gods->add_ordered(new Link{ { "Baldr", "Norse", "A giant ship called Hringorni", "None" } });
gods = gods->add_ordered(new Link{ { "Frejya", "Norse", "Chariot pulled by two cats", "Magic called seidr" } });
gods = gods->add_ordered(new Link{ { "Zeus", "Greek", "A chariot pulled by the four major winds shaped as horses",
"Thunderbolt and the shield called Aegis" } });
gods = gods->add_ordered(new Link{ { "Hera", "Greek", "A chariot drawn by peacocks", "Her intelligence" } });
gods = gods->add_ordered(new Link{ { "Athena", "Greek", "", "Allowed to use Zeus's Thunderbolt and the Aegis" } });
gods = gods->add_ordered(new Link{ { "Ares", "Greek", "War chariot", "Sword and spear" } });
gods = gods->add_ordered(new Link{ { "Amaterasu", "Japanese", "", "Sword of Kusanagi, Jewel of Yasakani, Mirror of Yata" } });
gods = gods->add_ordered(new Link{ { "Susanoo", "Japanese", "", "Sword of Totsuka" } });
gods = gods->add_ordered(new Link{ { "Izanagi", "Japanese", "", "Sword of Totsuka (later given to Susanoo)" } });
gods = gods->add_ordered(new Link{ { "Bishamonten", "Japanese", "", "A spear" } });
Link *Odin = new Link{ { "Odin", "Norse", "Eight-legged flying horse called Sleipnir", "Spear called Gungnir" } };
Link *Zeus = new Link{ { "Zeus", "Greek", "A chariot pulled by the four major winds shaped as horses",
"Thunderbolt and the shield called Aegis" } };
Link *Amaterasu = new Link{ { "Amaterasu", "Japanese", "", "Sword of Kusanagi, Jewel of Yasakani, Mirror of Yata" } };
Link *norse_gods = Odin;
Link *greek_gods = Zeus;
Link *jap_gods = Amaterasu;
while (gods->find_if_myth("Norse"))
{
move_nodes(norse_gods, gods, "Norse");
}
while (gods->find_if_myth("Greek"))
{
move_nodes(greek_gods, gods, "Greek");
}
while (gods->find_if_myth("Japanese"))
{
move_nodes(jap_gods, gods, "Japanese");
}
Link *trav = gods->find("Bihamonten");
if (trav)
{
trav->erase();
jap_gods = jap_gods->add_ordered(trav);
}
std::cout << "\nnorse_gods list:\n";
print_all(norse_gods);
std::cout << "\ngreek_gods list:\n";
print_all(greek_gods);
std::cout << "\njap_gods list:\n";
print_all(jap_gods);
std::cout << "\ngods list:\n";
print_all(gods);
delete Odin;
delete Zeus;
delete Amaterasu;
delete gods;
}
catch (const std::runtime_error &rte)
{
std::cerr << "Runtime error: " << rte.what() << '\n';
keep_window_open();
return 1;
}
catch (const std::bad_alloc &ba)
{
std::cerr << "Bad allocation error: " << ba.what() << '\n';
keep_window_open();
return 2;
}
catch (const std::exception &e)
{
std::cerr << "Exception: " << e.what() << "\n";
keep_window_open();
return 3;
}
catch (...)
{
std::cerr << "An unknown exception occurred\n";
keep_window_open();
return 4;
}
keep_window_open();
}
|