-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.c
More file actions
121 lines (111 loc) · 3.44 KB
/
Copy pathview.c
File metadata and controls
121 lines (111 loc) · 3.44 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* File: view.c
* Author: Bryan Daniel
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "view.h"
#include "fileutil.h"
#include "baseutil.h"
void print_main_menu()
{
printf("************************************************\n");
printf("* *\n");
printf("* SORTING ALGORITHM TESTER *\n");
printf("* *\n");
printf("************************************************\n");
printf("Main Menu:\n");
printf("1. Test Sorting Algorithms\n");
printf("2. Create New Test File.\n");
printf("3. Options.\n");
printf("4. Exit program.\n");
}
void print_algorithm_menu()
{
printf("Algorithm Options:\n");
printf("1. Bubble Sort\n");
printf("2. Quick Sort\n");
printf("3. Merge Sort\n");
printf("4. Return to Main Menu\n");
}
int print_file_menu(MenuOption *menu_options, char *directory_path)
{
int count = collect_directory_contents(menu_options, directory_path);
strcpy(menu_options[count].selection, "Return to Main Menu");
menu_options[count].menu_number = ++count;
printf("File Selection:\n");
for (int i = 0; i < count; i++)
{
printf("%d. %s\n", menu_options[i].menu_number, menu_options[i].selection);
}
return count;
}
void print_options_menu(ProgramOptions *options)
{
char choice;
int exit_options = 0;
while (exit_options == 0)
{
printf("Options:\n");
if (options->PrintList == ON)
{
printf("Printing currently turned on.\n");
printf("Turn printing off? Enter 'Y' for yes or 'N' to exit.\n");
scanf(" %c", &choice);
if (choice != 'Y' && choice != 'y' && choice != 'N' && choice != 'n')
{
printf("Invalid input.\n");
}
else if (choice == 'Y' || choice == 'y')
{
options->PrintList = OFF;
exit_options = 1;
printf("Printing successfully turned off.\n");
}
else
{
exit_options = 1;
}
}
else
{
printf("Printing currently turned off.\n");
printf("Turn printing on? Enter 'Y' for yes or 'N' to exit.\n");
scanf(" %c", &choice);
if (choice != 'Y' && choice != 'y' && choice != 'N' && choice != 'n')
{
printf("Invalid input.\n");
}
else if (choice == 'Y' || choice == 'y')
{
options->PrintList = ON;
exit_options = 1;
printf("Printing successfully turned on.\n");
}
else
{
exit_options = 1;
}
}
}
}
void print_file_creation_menu()
{
printf("New Test File:\n");
printf("1. Randomize existing test file\n");
printf("2. Create custom test file\n");
printf("3. Return to Main Menu\n");
}
int print_randomize_existing_file_options(MenuOption *menu_options)
{
printf("Test Files:\n");
int count = collect_directory_contents(menu_options, ProgramValues.test_directory_name);
strcpy(menu_options[count].selection, "Return to Previous Menu");
menu_options[count].menu_number = ++count;
for (int i = 0; i < count; i++)
{
printf("%d. %s\n", menu_options[i].menu_number, menu_options[i].selection);
}
return count;
}