示例#1
0
void search_classes()
{
    int done = FALSE;
    int choice = 0;
    char *answer, *dept_name;
    short course_num;
    int course_id;

    while(!done) {
        printf("Class Search\n");
        printf("0 - Go Back\n");
        printf("1 - Search by Professor Name (ex: Gerardo Chacon)\n");
        printf("2 - Search by Department Name (ex: MAT)\n");
        printf("3 - Search by Class ID (ex: MAT 150)\n");
        printf("4 - Search by Course ID (ex: 2600)\n");
        printf("Choice: ");
        choice = readnum(line, LINE_SIZE);
        if (choice == -1) {
            break;
        }

        switch(choice) {
        case 0:
            done = TRUE; break;
        case 1:
            printf("List Professors?\n");
            if (yes_no_input() == 1)
                list_professors();
            answer = answer_question("Enter professor's full name: ");
            list_classes_taught(get_professor(answer));
            break;
        case 2:
            printf("List Departments?\n");
            if (yes_no_input() == 1)
                list_departments();
            answer = answer_question("Enter Department name: ");
            list_dept_courses(get_department(answer));
            break;
        case 3:
            answer = answer_question("Enter Class ID: ");
            dept_name = strsep(&answer, " ");
            if (answer) {
                course_num = strtol(answer, NULL, 10);
                list_courses_by_num(dept_name, course_num);
            } else {
                printf("Bad Input\n");
            }
            break;
        case 4:
            answer = answer_question("Enter Course ID: ");
            course_id = strtol(answer, NULL, 10);
            list_courses_by_id(course_id);
            break;
        default:
            printf("Bad Input\n");
        }
    }

    printf("Returning to main menu\n");
}
static void menu_select_click_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *data ) {
    switch(cell_index->row) {
        case 0: {
            window_stack_pop(true);
            answer_question(QUESTION_ANSWER_SKIP);
            break;
        }
        case 1: {
            window_stack_pop(true);
            answer_question(QUESTION_ANSWER_REPORT);
            break;
        }
    }
}
示例#3
0
void make_quizz(Participant *p, int zaz,char ***o)
{
  int non;//si se me acabo la imaginacion

  for(non = 0; non < N; ++non)
    answer_question(p, zaz, o, non);
}
示例#4
0
student_t *register_student()
{
    student_t *student = NULL;
    char *answer;

    answer = answer_question("Enter name: ");
    student = create_student(answer);

    printf("Select a major\n");
    printf("List Departments?\n");
    if (yes_no_input() == 1)
        list_departments();

    answer = answer_question("Enter your Major's Department Name: ");
    if(!student->set_major(student, answer))
        printf("Bad Department Name\n");

    printf("Congratulations. You're read to start adding classes\n");
    return student;
}
示例#5
0
int main_body() {
    total = TOTAL;
	yes = 0;

	while(total > 0 ){
		print_math(TOTAL - total + 1);
		answer_question();
		total--;
    }
    return 0;
}
示例#6
0
/*
 Run the client server roleplay. 
 Note the user inputs for both parties.
 
 By Nicolas Knoebber and Erin Callaway
 */
int main()
{
  server_init();
  
  unsigned char server_pk[32];
  unsigned char init_sk[32];
  unsigned char nonce0[24];

  get_server_keys(server_pk,init_sk);
  getN0(nonce0);
  c_send_verif(server_pk,init_sk,nonce0);
  s_recieve_verif();
  c_recieve_verif(server_pk);
  ask_question(server_pk);
  answer_question();
  recieve_answer(server_pk);
  return 0;
}
示例#7
0
void add_class(student_t *student)
{
    int done = FALSE;
    int choice = 0;
    char *answer, dept_name[8], *pdept_name;
    short course_num;
    int course_id;
    course_t *course;

    while(!done) {
        printf("Add Class to Schedule\n");
        printf("0 - Go Back\n");
        printf("1 - Add by Class Num (ex: MAT 150)\n");
        printf("2 - Add by Course ID (ex: 2600)\n");
        printf("Choice: ");
        choice = readnum(line, LINE_SIZE);
        if (choice == -1)
            break;

        switch(choice) {
        case 0:
            done = TRUE; break;
        case 1:
            answer = answer_question("Enter Class ID: ");
            pdept_name = strsep(&answer, " ");
            if(!pdept_name || !answer || cgc_strlen(pdept_name) > 7) {
                printf("Bad Input\n");
                break;
            }
            strcpy(dept_name, pdept_name);
            course_num = strtol(answer, NULL, 10);
            printf("0 - Go Back\n");
            list_courses_by_num(dept_name, course_num);
            printf("Choice: ");
            choice = readnum(line, LINE_SIZE);
            if (choice && choice != -1) {
                course = select_course_num(dept_name, course_num, --choice);
                if (course) {
                    if (student->add_course(student, course))
                        printf("Successfully added course!\n");
                    else
                        printf("Could not add course.\n");
                } else {
                    printf("Bad selection\n");
                }
            }
            break;
        case 2:
            answer = answer_question("Enter Course ID: ");
            course_id = strtol(answer, NULL, 10);
            printf("0 - Go Back\n");
            list_courses_by_id(course_id);
            printf("Choice: ");
            choice = readnum(line, LINE_SIZE);
            if (choice && choice != -1) {
                course = select_course_id(course_id, --choice);
                if (course) {
                    if (student->add_course(student, course))
                        printf("Successfully added course!\n");
                    else
                        printf("Could not add course.\n");
                } else {
                    printf("Bad selection\n");
                }
            }
            break;
        default:
            printf("Bad Input\n");
        }
    }

    printf("Returning to main menu\n");
}