コード例 #1
0
ファイル: main.cpp プロジェクト: DaltheCow/CIS-277
//String Linked List functions
void airportMenu() {
    int choice = 1, distance = 0;
    string search;
    StringLinkedList list;
    list.createList();
    cout << "LGA is the first airport in this list." << endl;
    while (choice != 0) {
        switch (choice) {
            case 1: list.addNodeEnd(makeNewInfo());
                    cout << "Would you like to add another airport? (1 = yes, 2 = no)" << endl;
                    cin >> choice;
                    cout << endl;
                break;
            case 2: cout << "Select an airport code to search, its distance from LGA will be calculated:";
                    cin >> search;
                    distance = list.searchNodes(search);
                if (distance == 0) {
                    cout << "Please search for a valid code." << endl;
                }
                else {
                    cout << "Distance is " << distance << " miles." << endl;
                    cout << "Would you like to make another search? (1 = yes, 2 = no)" << endl;
                    cin >> choice;
                    choice ++;
                    if (choice == 3)
                        choice = 0;
                }
                break;
        }
    }
}