-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrafoPlanEstudio.h
More file actions
124 lines (123 loc) · 2.86 KB
/
Copy pathGrafoPlanEstudio.h
File metadata and controls
124 lines (123 loc) · 2.86 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#pragma once
#include "Grafos.h"
#include "PlanEstudio.h"
class GrafoPlanEstudio :public Base
{
private:
CGrafo<PlanEstudio>* grafo;
ofstream archivo;
Vector<string> planes;
int cantidad_planes;
int numeracion_aux;
public:
GrafoPlanEstudio()
{
planes = Vector<string>(100);
grafo = new CGrafo<PlanEstudio>();
cantidad_planes = 0;
lecturaArchivos();
lecturaDatos();
}
void menuPlanEstudio()
{
do
{
cout << " -------- Menu de Opciones de Plan de Estudios ----------" << endl << endl;
cout << " 1. Ingresar nuevo plan de estudios " << endl;
cout << " 2. Mostrar todas los planes de estudio " << endl;
cout << " 3. Salir " << endl;
cout << " ---------------------------------------------------" << endl;
verificarOpcion(3);
if (*opcion == 1) insertarPlanEstudio();
if (*opcion == 2) listar();
} while (*opcion != 3);
}
void lecturaArchivos()
{
string tmp;
int cont = 0;
ifstream miarchivo("PlanEstudio.txt");
if (!miarchivo.fail())
{
while (!miarchivo.eof())
{
getline(miarchivo, tmp);
planes.pushBack(tmp);
//grafo->adicionarVertice(tmp); //inserta la info en el vertice sin arco
cantidad_planes++;
}
miarchivo.close();
}
}
void lecturaDatos()
{
int id = 1;
for (int i = 0; i < cantidad_planes - 1; i++)
{
int size = planes.at(i).size();
int tmp = 0;
string curso = "";
string tema = "";
string aux2 = "";
Vector<string>* aux = new Vector<string>(50);
for (int j = 0; j < size; j++)
{
if (planes.at(i)[j] != '/')
{
aux2 = aux2 + planes.at(i)[j];
}
else
{
if (tmp == 0) curso = aux2;
else aux->pushBack(aux2);
aux2 = "";
tmp++;
}
}
int a = grafo->adicionarVertice(PlanEstudio(curso, aux));
id++;
}
numeracion_aux = id;
}
void insertarPlanEstudio()
{
archivo.open("PlanEstudio.txt", ofstream::app);
string curso, tema, cantidad,opcion;
Vector<string>* temas = new Vector<string>(50);
int numeracion = numeracion_aux;
char opt;
archivo.open("PlanEstudio.txt", ofstream::app);
do
{
cout << "Nombre del curso:" << endl;
getline(cin, curso);
archivo << curso << "/";
cout << "Numero de modulos(temas):" << endl;
getline(cin, cantidad);
int cant = stoi(cantidad);
for (size_t i = 0; i < cant; i++)
{
cout << "Nombre del tema :" << endl;
getline(cin, tema);
archivo << tema << "/";
temas->pushBack(tema);
}
archivo << endl;
cantidad_planes++;
grafo->adicionarVertice(PlanEstudio(curso,temas));
numeracion++;
cout << "Desea continuar registrando un usuario (Si: S, No:N)";
getline(cin, opcion);
opt = toupper(opcion[0]);
} while (opt != 'N');
archivo.close();
system("CLS");
}
void listar()
{
for (int i = 0; i < grafo->cantidadVertices(); i++)
{
cout << i << ". " << grafo->obtenerVertice(i).toString() << endl;
}
}
};