Advertisement
Guest User

CODIGO

a guest
Aug 7th, 2014
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.00 KB | None | 0 0
  1. (CLASE LISTA)
  2. ifndef LISTA_H
  3. #define LISTA_H
  4. #include "Nodo.h"
  5. class Lista{
  6. private:
  7. pnodo primero;
  8. pnodo actual;
  9. bool ListaVacia(){
  10. return (this->primero==NULL);
  11. }
  12. public:
  13. Lista(){
  14. this->primero = NULL;
  15. this->actual = NULL;
  16. }
  17. ~Lista(){
  18. while (this->primero){
  19. pnodo tmp = this->primero;
  20. this->primero = tmp->Siguiente;
  21. delete tmp;
  22. }
  23. }
  24. void Agregar(estudiantes v){
  25. pnodo nuevo = new Nodo(v);
  26. if (this->ListaVacia())
  27. this->primero = nuevo;
  28. else
  29. this->actual->Siguiente =nuevo;
  30. this->actual = nuevo;
  31. }
  32. void Mostrar(){
  33. if (!this->ListaVacia()){
  34. pnodo tmp = this->primero;
  35. while (tmp){
  36. cout << tmp->Valor;
  37. tmp = tmp->Siguiente;
  38. }
  39. cout << "NULL\n";
  40. }
  41.  
  42. }
  43. pnodo Buscar(estudiantes v){
  44. pnodo tmp;
  45. bool encontrado = false;
  46. if (ListaVacia())
  47. tmp = NULL;
  48. else{
  49. tmp = this->primero;
  50. while (tmp && !encontrado){
  51. if (tmp->Valor == v){
  52. encontrado = true;
  53. }
  54. else{
  55. tmp = tmp->Siguiente;
  56. }
  57. }
  58. }
  59. return tmp;
  60.  
  61. }
  62. bool Eliminar(list <estudiantes>& L){}
  63. list<estudiantes>::iterator it = L.begin();
  64. while (it != L.end()) {
  65. if (!estudiantes (*it)) {
  66. L.erase(it);
  67. } else {
  68. it++;
  69. }
  70. }
  71. }
  72.  
  73. bool Modificar(estudiantes v, estudiantes n){}
  74.  
  75.  
  76. return v.Nombre < n.Nombre;
  77.  
  78. void Ordenar(const list<int>& L) {
  79. cout << '[';
  80. list<int>::iterator it = L.begin();
  81. if (it != L.end()) {
  82. cout << *it;
  83. for (it++; it != L.end(); it++) {
  84. cout << ' ' << *it;
  85. }
  86. }
  87. cout << ']';
  88. }
  89.  
  90. };
  91. #endif
  92. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  93. (CLASE FECHA)
  94. #ifndef FECHA_H
  95. #define FECHA_H
  96.  
  97. class fecha{
  98. private:
  99. int d;
  100. int m;
  101. int a;
  102.  
  103. public:
  104. fecha(int dd, int mm, int aa){
  105. this->d = dd;
  106. this->m = mm;
  107. this->a = aa;
  108. }
  109. void MostrarFecha(){
  110. cout << this->d << "/" << this->m << "/" <<this->a;
  111. }
  112.  
  113. bool ValidarFecha(){
  114. return true;
  115. }
  116.  
  117.  
  118. #endif
  119. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  120. (MAIN)
  121. #include <iostream>
  122. using namespace std;
  123. #include "Lista.h"
  124. int main(){
  125. Lista lst;
  126. lst.Agregar(new estudiantes);
  127. lst.Buscar(new estudiantes);
  128. lst.Modificar(new estudiantes);
  129. lst.Eliminar(new estudiantes);
  130. lst.Mostrar(new estudiantes);
  131. pnodo elemento = lst.Buscar(new estudiantes);
  132. if (elemento){
  133. cout << elemento->getValor();
  134. }
  135. else{
  136. cout << "No estaba en la lista\n";
  137. }
  138.  
  139. return 0;
  140. }
  141. int op;
  142. fecha fe;
  143. estudiantes est;
  144. Lista lst;
  145. persona p;
  146.  
  147. do{
  148. system("cls");
  149.  
  150. cout << "*************************************\n";
  151. cout << "* MENU DE OPCIONES *\n";
  152. cout << "*************************************\n";
  153. cout << "* 1. Agregar Estudiantes *\n";
  154. cout << "* 2. Buscar *\n";
  155. cout << "* 3. Modificar Lista de Estudiantes *\n";
  156. cout << "* 4. Eliminar Estudiantes *\n";
  157. cout << "* 5. Mostrar *\n";
  158. cout << "* 6. Ordenar *\n";
  159. cout << "*************************************\n";
  160. cout << "\nDigite su opcion: ";
  161. cin >> op;
  162.  
  163. switch(op){
  164. case 1:
  165. cout << "\nAGREGAR ESTUDIANTE: \n\n" ;
  166. fe = pedir();
  167. traa = pedirdato();
  168. lst.Insertar(est);
  169. cod++;
  170. break;
  171.  
  172. case 2:
  173. cout << "\nBUSCAR ESTUDIANTE \n\n";
  174. cout << "Digite el apellido del Estudiante: ";
  175. cin >> Apellido;
  176. system("cls");
  177. int op;
  178.  
  179. if(op==1){
  180. lst.buscar1(Apellido);
  181. cout << "Apellido:\t\t";
  182. traa.mostrarnombresmayusculas();
  183. cout << endl;
  184. traa.getPromedio();
  185. void MostrarFecha();
  186. cout << "Fecha de Nacimiento: ";
  187. fe.MostrarFecha();
  188.  
  189. }
  190. else{
  191. lst.buscar1(Nombre);
  192. cout << "Nombres:\t\t";
  193. traa.mostrarnombresminusculas();
  194. cout << endl;
  195. traa.getPromedio();
  196. void MostrarFecha();
  197. cout << "Fecha de Nacimiento: ";
  198. fe.MostrarFecha();
  199. cout << "\n" << "\n";
  200. fe.MostrarCalendario();
  201. cout << "\n";
  202. }
  203. break;
  204.  
  205. case 3:
  206. cout << "\Modificar \n\n";
  207. lst.Mostrar();
  208. break;
  209.  
  210. case 4:
  211. cout << "ELIMINAR" ;
  212. int e;
  213. cout << "A quien quiere eliminar: ";
  214. cin >> e;
  215. lst.EliminarEnmedio(e);
  216.  
  217. case 5:
  218. cout << "\nMOSTRAR LISTA" << endl;
  219. this->lst.Mostrar();
  220. break;
  221. }
  222. case 6:
  223. cout<<"ORDENAR:";
  224. string n;
  225. list<string> L;
  226. while (cin >> n) {
  227. L.push_back(n);
  228. }
  229. L.sort();
  230. list<string>::iterator it = L.begin();
  231. for (; it != L.end(); it++) {
  232. cout << *it << ' ';
  233. }
  234. }
  235.  
  236. fecha pedir(){
  237. fecha fe;
  238. int d, m, a;
  239. cout << "\nIngrese feha de nacimiento dd/mm/aa \n\n";
  240. cout << "Dia: ";
  241. cin >> d;
  242. cout << "Mes: ";
  243. cin >> m;
  244. cout << "Anyo: ";
  245. cin >> a;
  246. fe = fecha(d,m,a);
  247.  
  248. return fe;
  249. }
  250.  
  251. estudiantes pedirdato(){
  252. estudiantes est;
  253. char Nombre[TAM],Apellido[TAM];
  254. cout << "\nIngrese su nombre: ";
  255. cin >> Nombre;
  256. cout << "\nIngrese su apellido: ";
  257. cin >> Apellido;
  258. cout << "\nIngrese Nota1: ";
  259. cin >> Nota1;
  260. cout << "\nIngrese Nota2: ";
  261. cin >>Nota2;
  262. cout << "\nIngrese Nota3: ";
  263. cin >> Nota3;
  264. est = estudiantes(Nombre,Apellido,s);
  265.  
  266. return est;
  267. }
  268.  
  269. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  270. (CLASE NODO)
  271. #ifndef NODO_H
  272. #define NODO_H
  273. #include <stdlib.h>
  274. #include "personas.h"
  275. class Nodo{
  276. private:
  277. estudiantes Valor;
  278. Nodo *Siguiente;
  279. public:
  280. Nodo(estudiantes est=0, Nodo* sig=NULL){
  281. this->Valor=est;
  282. this->Siguiente = sig;
  283. }
  284. friend class Lista;
  285. //int getValor(){
  286. //return this->Valor;
  287.  
  288. };typedef Nodo *pnodo;
  289.  
  290. #endif
  291. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  292. (CLASE PERSONAS)
  293. ifndef PERSONAS_H
  294. #define PERSONAS_H
  295. #include "fecha.h"
  296. #define TAM 10
  297. #include <String.h>
  298.  
  299. class personas{
  300. private:
  301. char Nombre [TAM];
  302. char Apellido [TAM];
  303. fecha *FechaNac;
  304.  
  305. public:
  306. personas (char N[], char A[], fecha *fn){
  307. strcpy(this->Nombre,N);
  308. strcpy(this->Apellido,A);
  309. this->FechaNac = fn;
  310.  
  311. }
  312. Void MostrarNomAp(){
  313. cout<<this->Nombre<<" "<<this->Apellido;
  314.  
  315. }
  316. Void MostrarFecha(){
  317. this->FechaNac->MostrarFecha();
  318. }
  319. friend class estudiantes;
  320. };
  321.  
  322.  
  323.  
  324.  
  325. #endif
  326. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  327. (CLASE ESTUDIANTES)
  328. #ifndef ESTUDIANTES_H
  329. #define ESTUDIANTES_H
  330. #include "personas.h"
  331.  
  332. class estudiantes: public personas{
  333. private:
  334. float Nota1;
  335. float Nota2;
  336. float Nota3;
  337. float Promedio;
  338.  
  339. public:
  340. estudiantes (char N[], char A[], fecha *fn, float n1, float n2, float n3, float Promedio){
  341. this->Nota1=n1;
  342. this->Nota2=n2;
  343. this->Nota3=n3;
  344. this->Promedio=(Nota1+Nota2+Nota3)/3;
  345.  
  346. float getPromedio(){
  347. cout << "Promedio: \t" << this->Promedio<< endl;
  348. return 0;
  349.  
  350.  
  351.  
  352. };
  353.  
  354. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement