-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparty.cpp
More file actions
79 lines (72 loc) · 1.77 KB
/
party.cpp
File metadata and controls
79 lines (72 loc) · 1.77 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
#include "party.h"
#include <fstream>
#include <iostream>
using std::ifstream;
using std::ios;
using std::ofstream;
extern void GetPartyIdNo();
extern void SetPartyIdNo();
extern int partyId;
Party::Party()
{
PartyID = 0;
votes = 0;
Members = 0;
seats = 0;
strcpy(partyName, "NoName");
strcpy(headName, "NoName");
setPassword("1234");
}
void Party::getPartyInfo()
{
GetPartyIdNo();
PartyID = ++partyId;
SetPartyIdNo();
// partyCount++;
votes = 0;
seats = 0;
Members = 1;
std::cin.ignore();
std::cout << "Enter the PartyName : ";
std::cin.getline(partyName, 49);
std::cout << "\n Enter the HeadName : ";
std::cin.getline(headName, 24);
char arr[10], cr;
std::cout << "\n Enter the Password : ";
std::string password;
do
{
// std::cin.ignore();
std::getline(std::cin >> std::ws, password);
if (password.length() > 10)
{
std::cout << "Password length cannot be more than 10." << std::endl;
}
} while (password.length() > 10);
setPassword(password.c_str());
}
void Party::getParty(int x)
{
int i = 0;
ifstream finPartyRecord;
finPartyRecord.open("Party.txt", ios::in | ios::binary);
if (!finPartyRecord)
{
std::cout << "\n File not Found";
}
else
{
while (!finPartyRecord.eof() && i != x + 1)
{
finPartyRecord.read(reinterpret_cast<char *>(this), sizeof(*this));
i++;
}
}
}
void Party::storeParty()
{
ofstream foutParty;
foutParty.open("Party.txt", ios::app | ios::binary);
foutParty.write(reinterpret_cast<char *>(this), sizeof(*this));
foutParty.close();
}