Exemplo n.º 1
0
void UI::menu(char ans)
{
    switch(ans) {
        case 'a':
        case 'A':   addIndividual();
                    break;
        case 's':
        case 'S':   searchMenu();
                    break;
        case 'p':
        case 'P':   sortMenu();
                    break;
        case 'r':
        case 'R':   remove();
                    break;
        case 'l':
        case 'L':   cout << "The current size of this list is: " << core.getSizeOfList() << endl;
                    break;
        case 'q':
        case 'Q':   cout << endl;
                    exit(1);
                    break;
        default:    cout << "Incorrect input, please try again!" << endl;
                    break;
    }
}
Exemplo n.º 2
0
Arquivo: p1_main.c Projeto: syzhou/p1
int main() {
	while (1) {
		char cmd1;
		char cmd2;
		struct Ordered_container* people;
		people = OC_create_container((OC_comp_fp_t)comparePeople);
		printf("\nEnter command: ");
		scanf(" %c", &cmd1);
		scanf("%c", &cmd2);
		switch (cmd1) {
		case 'p':
			break;
		case 'a':
			switch (cmd2) {
			case 'i':
			{
				addIndividual(people);
			}
				break;

			default:
				printErrUnrecCmd();
				break;
			}
			break;
		case 'r':
			break;
		case 'd':
			break;
		case 's':
			break;
		case 'l':
			break;
		case 'q':
			switch (cmd2) {
			case 'q' :
				return 0;
				break;
			default:
				printErrUnrecCmd();
				break;
			}
			break;
		default:
			printErrUnrecCmd();
			break;
		}
	}
	return 0;
}
Exemplo n.º 3
0
void FamilyTree::loadGEDCOM(const char* iFileName)
{
    lube::filemodule gm("ged");
    lube::file& vf = gm.create();
    var ged = vf.read(iFileName);

    std::cout << "Individuals: " << ged["Individual"].size() << std::endl;
    std::cout << "Families: " << ged["Family"].size() << std::endl;

    // Add to graph
    for (int i=0; i<ged["Individual"].size(); i++)
    {
        // Rely on vertex, returned by add_vertex(), just being an
        // integer that increments with each call.
        vertex v = addIndividual();
        if ((int)v != i)
            throw std::runtime_error(
                "FamilyTree::loadGEDCOM: vertex out of order"
            );
        var& ind = getIndividual(v);
        ind = ged["Individual"][i];
    }
    for (int i=0; i<ged["Family"].size(); i++)
    {
        var f = ged["Family"][i];
        var h = f.at("HUSB");
        var w = f.at("WIFE");
        h.dereference();
        w.dereference();
        for (int c=0; c<f["CHIL"].size(); c++)
        {
            var k = f["CHIL"][c];
            if (h)
                addRelationship(h.cast<int>(), k.cast<int>());
            if (w)
                addRelationship(w.cast<int>(), k.cast<int>());
        }
    }
}
Exemplo n.º 4
0
Population::Population()
{
    addIndividual(30);
}
Exemplo n.º 5
0
Arquivo: p1_main.c Projeto: syzhou/p1
int main() {
	struct Ordered_container* people;
	struct Ordered_container* rooms;
	people = OC_create_container((OC_comp_fp_t)comparePeople);
	rooms = OC_create_container((OC_comp_fp_t)compareRooms);
	while (1) {
		char cmd1;
		char cmd2;
		printf("\nEnter command: ");
		scanf(" %c", &cmd1);
		scanf("%c", &cmd2);
		switch (cmd1) {
		case 'p':
			switch (cmd2) {
			case 'i':
				printIndividual(people);
				break;
			case 'r':
				printRoom(rooms);
				break;
			case 'm':
				printMeeting(rooms);
				break;
			case 's':
				printSchedule(rooms);
				break;
			case 'g':
				printGroup(people);
				break;
			default:
				printErrUnrecCmd();
				break;
			}
			break;
		case 'a':
			switch (cmd2) {
			case 'i':
				addIndividual(people);
				break;
			case 'r':
				addRoom(rooms);
				break;
			case 'm':
				addMeeting(rooms);
				break;
			case 'p':
				addParticipant(rooms, people);
				break;
			default:
				printErrUnrecCmd();
				break;
			}
			break;
		case 'r':
			switch (cmd2) {
			case 'm':
				rescheduleMeeting(rooms);
				break;
			default:
				printErrUnrecCmd();
				break;
			}
			break;
		case 'd':
			switch (cmd2) {
			case 'i':
				deleteIndividual(people, rooms);
				break;
			case 'r':
				deleteRoom(rooms);
				break;
			case 'm':
				deleteMeeting(rooms);
				break;
			case 'p':
				deleteParticipant(rooms, people);
				break;
			case 's':
				deleteSchedule(rooms);
				break;
			case 'g':
				deleteGroup(rooms, people);
				break;
			case 'a':
				deleteAll(rooms, people);
				break;
			default:
				printErrUnrecCmd();
				break;
			}
			break;
		case 's':
			break;
		case 'l':
			break;
		case 'q':
			switch (cmd2) {
			case 'q' :
				printf("All meetings deleted\n");
				printf("All rooms deleted\n");
				printf("All persons deleted\n");
				printf("Done\n");
				return 0;
				break;
			default:
				printErrUnrecCmd();
				break;
			}
			break;
		default:
			printErrUnrecCmd();
			break;
		}
	}
	return 0;
}