-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGroup.cpp
More file actions
102 lines (85 loc) · 1.83 KB
/
Group.cpp
File metadata and controls
102 lines (85 loc) · 1.83 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
/*
* File: Group.cpp
* Author: akhfa
*
* Created on December 3, 2014, 10:01 AM
*/
#include "Group.h"
Group::Group() {
}
Group::Group(const Group& orig) {
}
Group::~Group() {
}
void Group::newGroup(char* namaGroup)
{
ofstream file;
file.open(namaGroup,ios::app);
file.close();
}
void Group::addNewMemberGroup(char* namaGroup, string namaUser)
{
ofstream file;
file.open(namaGroup,ios::app);
if(file.is_open())
{
file << namaUser << endl;
file.close();
}
else
{
cout << "File tidak berhasil dibuka";
}
}
list<string> Group::getDaftarUser(char* filename)
{
ifstream file;
string user;
list <string> daftarUser;
file.open(filename);
if(file.is_open())
{
while(getline(file,user))
{
daftarUser.push_back(user);
}
}
return daftarUser;
}
void Group::simpanGrupMessage(char* grupName, string waktu, string namaUser, string message)
{
ofstream file;
file.open(grupName,ios::app);
// string line;
if(file.is_open())
{
file << waktu << " : " << namaUser << " : " << message << endl;
file.close();
}
}
string Group::getCurrentTime()
{
time_t t = time(0); // get time now
struct tm * now = localtime( & t );
char buffer[50];
int i;
itoa(now->tm_year + 1900,buffer, 10);
string date;
date.append(buffer);
date.append("-");
itoa(now->tm_mon + 1, buffer, 10);
date.append(buffer);
date.append("-");
itoa(now->tm_mday,buffer, 10);
date.append(buffer);
date.append(" | ");
itoa(now->tm_hour, buffer, 10);
date.append(buffer);
date.append(":");
itoa(now->tm_min, buffer, 10);
date.append(buffer);
date.append(":");
itoa(now->tm_sec, buffer, 10);
date.append(buffer);
return date;
}