-
Notifications
You must be signed in to change notification settings - Fork 0
/
MENU.CPP
124 lines (121 loc) · 1.5 KB
/
MENU.CPP
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
122
123
124
#include<stdio.h>
#include<conio.h>
#include<bios.h>
#include<iostream.h>
#include<process.h>
#include<string.h>
#define max 6
class menu
{
char a[max][20];
int x,y;
public:
menu(int,int);
int action(int);
int arrow();
void disp(int);
};
menu::menu(int a1=1,int b=1)
{
char t[max][20]={"New Account","Balance Check","Cash Deposit","Cash Withdrawal","Delete Account","Exit"};
int i;
for(i=0;i<max;i++)
strcpy(a[i],t[i]);
x=a1;
y=b;
}
void menu::disp(int n)
{
int i,x1=x,y1=y;
textbackground(BLACK);
clrscr();
for(i=0;i<max;i++)
{
gotoxy(x1,y1);
if(n==i)
{
textbackground(WHITE);
textcolor(BLACK);
}
else
{
textbackground(BLACK);
textcolor(WHITE);
}
cprintf("%s",a[i]);
y1+=2;
}
}
int menu::arrow()
{
int ch,temp;
static int i=0;
disp(i);
do
{
ch=bioskey(0);
if(ch==18432)
i--;
if(ch==20480)
i++;
if(i==-1)
i=max-1;
if(i==max)
i=0;
if(ch==7181)
{
clrscr();
temp=action(i);
return temp;
getch();
}
disp(i);
}
while(ch!=283);
//return i;
}
int menu::action(int ch)
{
int v;
switch(ch)
{
case 0:v=1;
break;
case 1:v=2;
break;
case 2:v=3;
break;
case 3:v=4;
break;
case 4:v=5;
break;
case 5:exit(0);
}
return v;
}
void main()
{
int my;
int ops;
do
{
menu m(35,5);
clrscr();
my=m.arrow();
switch(my)
{
case 1:cout<<"add";
break;
case 2:cout<<"search";
break;
case 3:cout<<"deposit";
break;
case 4:cout<<"Withdraw";
break;
default:exit(0);
}
cout<<"\nDo you want to continue";
cin>>ops;
getch();
}while(ops!='n');
}