-
Notifications
You must be signed in to change notification settings - Fork 0
/
g.cpp
121 lines (93 loc) · 2.58 KB
/
g.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
#include<iostream>
#include<string>
using namespace std;
class CLIENT
{
long int kwdikospelath;
char[30] onomapelath;
char[5] loginname;
long int password;
float kostosKWh;
float megistoypoloipo;
float teleutaiametrhsh;
float ypoloipo;
public:
CLIENT(void);
long int getkwdikospelath(void){return kwdikospelath;}
char
}
CLIENT::CLIENT(void)
{ cout<<"dwse me th seira pou zhtountai kwdiko pelath,onomapelath,loginname,password,kostosKWh,megistoypoloipo";
cin>>kwdikospelath>>onomapelath>>loginname>>password>>kostosKWh>>megistoypoloipo;
ypoloipo=0;
teleutaiametrhsh=0;
}
void main
{
CLIENT *pelates; //pointer poy deixnei ston pinaka twn antikeimenwn
int a; // shmaia gia server h pelath
int counter=0; //metrhths gia to posa antikeimena exoume
while(1){
cout<<"an eisai diaxeiristis dwse thn timh 1,an eisai pelaths dwse opoiadhpote allh timh";
cin>>a
if(a==1)
{if(server(counter,pelates)==1){exit};
}
else
{pelaths(counter,pelates);
}
}
}
void pelaths(int counter,CLIENT *pelates)
{ int i;
int c=0;
cout<<"dwse mou to login name kai to password sou";
cin>>loginnam>>passwor;
for(i==0,i<counter,i++)
{if((pelates[i].loginname==loginnam)and(pelates[i].password==passwor))
{ c=i;
break; //exodos apo to for
}
}
if((i==counter)and(c==0))
{
cout<<"den vrethike pelaths";
exit; //εξοδος απο την συναρτηση πελατη επειδη δεν βρεθηκε ο πελατης
}
cout<<"parakalw plhktrologeiste to poso pou tha thelate na exoflhsete kathws kai arithmo logariasmou";
cin>>poso>>arithlogar;
pelates[c].ypoloipo=pelates[c].ypoloipo-poso;
cout<<poso<<"$ "<<arithlogar;
}
void server(int counter,CLIENT *pelates)
{ int exit=0;
int i==3;
int leitourgia;
while(i==3)
{
cout<<"gia neo pelath pathste 1";
cout<<"gia diagrafi pelath pathste 2";
cout<<"gia diagrafi aytwn poy xrvstane polla pathste 3";
cout<<"gia ektypvsh olwn twn pelatvn pathste 4";
cout<<"gia exodo apo to programma pathste 5";
cout<<"gia exodo apo to menu pathste 6";
cin>>leitourgia;
if(leitourgia==1)
{
neos_pelaths();
}
elseif(leitourgia==2){diagrafi_pelath();}
elseif(leitourgia==3)
{diagrafi_ofeiletwn();
i++}
elseif(leitourgia==4)
{
ektypwsh_pelatwn();
i++;
}
elseif(leitourgia==5){
i++;
exit=1;
return exit;}
}
}