-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterface.c
More file actions
64 lines (60 loc) · 1.61 KB
/
Interface.c
File metadata and controls
64 lines (60 loc) · 1.61 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
/*
* Interface.c
*
* Created on: 30.03.2017
* Author: longman
*/
#include "Interface.h"
void printMenu(void){
for(int i = 0 ; i<=EXIT ; i++){
printf("%d : %s\n",i,getOptionName(i));
}
}
const char* getOptionName(enum Options o){
switch(o){
case TIME_SPECTRUM : return "Time spectrum";
case TEMP_SPECTRUM : return "Temperature spectrum";
case SET_TMIN : return "Set starting temperature";
case SET_TMAX : return "Set maximum temperature";
case SET_DELTAT : return "Set temperature delta";
case SET_TEMP : return "Set temperature";
case SET_SPINS : return "Set spins (-1,0,+1) ";
case SET_N_EDGES : return "Set number of edges";
case SET_N_NODES : return "Set number of nodes";
case CREATE_GRAPH : return "Create new Graph";
case TC_N_NODES : return "Critical Temperature(N) ";
case CRITICAL_TEMP_PLOT : return "Critical Temperature(K) ";
case EXIT : return "Exit";
default : return "No such option";
}
}
SPIN getSpinSelect(void){
fprintf(stdout," %d: Spins Up\n %d: Spins down \n %d: Spins random\n",SPIN_UP,SPIN_DOWN,SPIN_RANDOM);
SPIN choice=0;
if(scanf("%d",&choice)){
fprintf(stdout,"Selected : %d \n",choice);
}
else
fprintf(stdout,"ERROR returning %d",choice);
return choice;
}
float getXSelect(enum Options o){
float X=0.0f;
puts(getOptionName(o));
if(scanf("%f",&X)){
fprintf(stdout,"Selected : %f \n",X);
}
else
fprintf(stdout,"ERROR returning %f",X);
return X;
}
int getNSelect(enum Options o){
puts(getOptionName(o));
int choice=0;
if(scanf("%d",&choice)){
fprintf(stdout,"Selected : %d \n",choice);
}
else
fprintf(stdout,"ERROR returning %d",choice);
return choice;
}