0 / 0 / 0
Регистрация: 22.06.2016
Сообщений: 8
|
|
1
|
Переделать код под ООП
25.06.2016, 02:34. Показов 592. Ответов 0
Помогите пожалуйста. Необходимо переделать данный код под ООП. Очень срочно, люди добрые. Помогите, буду век благодарен
C++ | 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
| #include "stdafx.h"
#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/istreamwrapper.h"
#include <iostream>
#include "rapidjson/prettywriter.h"
#include <string>
#include <fstream>
using namespace rapidjson;
using namespace std;
int main() {
std::ifstream ifs("test-json-file.json");
IStreamWrapper isw(ifs);
Document documentFromFile;
documentFromFile.ParseStream(isw);
std:string slovo;
std::cout << "Vvedite name" << std::endl;
std::cin >> slovo;
struct mystruct{
char b[20];
char c[20];
char d[20];
char e[20];
char f[20];
char g[20];
char k[30];
};
mystruct str1[20];
mystruct str2[20];
mystruct str3[20];
mystruct str4[20];
mystruct str5[20];
mystruct str6[20];
mystruct str7[20];
//с учетом одного предка
strcpy_s(str1[0].b, "/courses/teacher");
strcpy_s(str2[0].e, "/courses/subject");
strcpy_s(str5[0].f, "/students/name1");
strcpy_s(str6[0].g, "/students/name2");
strcpy_s(str7[0].k, "/abiturient/name3");
if (str1[0].b == slovo)
{
std::cout << "/courses/"<< "teacher/" <<("%s\n", documentFromFile["courses"]["teacher"].GetString()) << std::endl;
}
else if (str4[0].e == slovo)
{
std::cout << "/courses/" <<"subject/" <<("%s\n", documentFromFile["courses"]["subject"].GetString()) << std::endl;
}
else if (str5[0].f == slovo)
{
std::cout << "/students/" <<"name1/" << ("%s\n", documentFromFile["courses"]["students"]["name1"].GetString()) << std::endl;
}
else if (str6[0].g == slovo)
{
std::cout << "/students/" << "name2/" << ("%s\n", documentFromFile["courses"]["students"]["name2"].GetString()) << std::endl;
}
else if (str7[0].k == slovo)
{
std::cout << "/abiturient/" << "name3/" << ("%s\n", documentFromFile["courses"]["students"]["abiturient"]["name3"].GetString()) << std::endl;
} |
|
Содержимое файла test-json-file.json
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| {
"namse": "univer",
"address": "Bluher",
"b": [1,2,3,4],
"courses":
{
"subject": "mathematic",
"teacher": "John Malkovich",
"students":
{
"name1":"Bobby",
"name2":"Sam",
"abiturient":
{
"name3":"Kirill"
}
}
}
} |
|
0
|