Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (CLASE LISTA)
- ifndef LISTA_H
- #define LISTA_H
- #include "Nodo.h"
- class Lista{
- private:
- pnodo primero;
- pnodo actual;
- bool ListaVacia(){
- return (this->primero==NULL);
- }
- public:
- Lista(){
- this->primero = NULL;
- this->actual = NULL;
- }
- ~Lista(){
- while (this->primero){
- pnodo tmp = this->primero;
- this->primero = tmp->Siguiente;
- delete tmp;
- }
- }
- void Agregar(estudiantes v){
- pnodo nuevo = new Nodo(v);
- if (this->ListaVacia())
- this->primero = nuevo;
- else
- this->actual->Siguiente =nuevo;
- this->actual = nuevo;
- }
- void Mostrar(){
- if (!this->ListaVacia()){
- pnodo tmp = this->primero;
- while (tmp){
- cout << tmp->Valor;
- tmp = tmp->Siguiente;
- }
- cout << "NULL\n";
- }
- }
- pnodo Buscar(estudiantes v){
- pnodo tmp;
- bool encontrado = false;
- if (ListaVacia())
- tmp = NULL;
- else{
- tmp = this->primero;
- while (tmp && !encontrado){
- if (tmp->Valor == v){
- encontrado = true;
- }
- else{
- tmp = tmp->Siguiente;
- }
- }
- }
- return tmp;
- }
- bool Eliminar(list <estudiantes>& L){}
- list<estudiantes>::iterator it = L.begin();
- while (it != L.end()) {
- if (!estudiantes (*it)) {
- L.erase(it);
- } else {
- it++;
- }
- }
- }
- bool Modificar(estudiantes v, estudiantes n){}
- return v.Nombre < n.Nombre;
- void Ordenar(const list<int>& L) {
- cout << '[';
- list<int>::iterator it = L.begin();
- if (it != L.end()) {
- cout << *it;
- for (it++; it != L.end(); it++) {
- cout << ' ' << *it;
- }
- }
- cout << ']';
- }
- };
- #endif
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- (CLASE FECHA)
- #ifndef FECHA_H
- #define FECHA_H
- class fecha{
- private:
- int d;
- int m;
- int a;
- public:
- fecha(int dd, int mm, int aa){
- this->d = dd;
- this->m = mm;
- this->a = aa;
- }
- void MostrarFecha(){
- cout << this->d << "/" << this->m << "/" <<this->a;
- }
- bool ValidarFecha(){
- return true;
- }
- #endif
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- (MAIN)
- #include <iostream>
- using namespace std;
- #include "Lista.h"
- int main(){
- Lista lst;
- lst.Agregar(new estudiantes);
- lst.Buscar(new estudiantes);
- lst.Modificar(new estudiantes);
- lst.Eliminar(new estudiantes);
- lst.Mostrar(new estudiantes);
- pnodo elemento = lst.Buscar(new estudiantes);
- if (elemento){
- cout << elemento->getValor();
- }
- else{
- cout << "No estaba en la lista\n";
- }
- return 0;
- }
- int op;
- fecha fe;
- estudiantes est;
- Lista lst;
- persona p;
- do{
- system("cls");
- cout << "*************************************\n";
- cout << "* MENU DE OPCIONES *\n";
- cout << "*************************************\n";
- cout << "* 1. Agregar Estudiantes *\n";
- cout << "* 2. Buscar *\n";
- cout << "* 3. Modificar Lista de Estudiantes *\n";
- cout << "* 4. Eliminar Estudiantes *\n";
- cout << "* 5. Mostrar *\n";
- cout << "* 6. Ordenar *\n";
- cout << "*************************************\n";
- cout << "\nDigite su opcion: ";
- cin >> op;
- switch(op){
- case 1:
- cout << "\nAGREGAR ESTUDIANTE: \n\n" ;
- fe = pedir();
- traa = pedirdato();
- lst.Insertar(est);
- cod++;
- break;
- case 2:
- cout << "\nBUSCAR ESTUDIANTE \n\n";
- cout << "Digite el apellido del Estudiante: ";
- cin >> Apellido;
- system("cls");
- int op;
- if(op==1){
- lst.buscar1(Apellido);
- cout << "Apellido:\t\t";
- traa.mostrarnombresmayusculas();
- cout << endl;
- traa.getPromedio();
- void MostrarFecha();
- cout << "Fecha de Nacimiento: ";
- fe.MostrarFecha();
- }
- else{
- lst.buscar1(Nombre);
- cout << "Nombres:\t\t";
- traa.mostrarnombresminusculas();
- cout << endl;
- traa.getPromedio();
- void MostrarFecha();
- cout << "Fecha de Nacimiento: ";
- fe.MostrarFecha();
- cout << "\n" << "\n";
- fe.MostrarCalendario();
- cout << "\n";
- }
- break;
- case 3:
- cout << "\Modificar \n\n";
- lst.Mostrar();
- break;
- case 4:
- cout << "ELIMINAR" ;
- int e;
- cout << "A quien quiere eliminar: ";
- cin >> e;
- lst.EliminarEnmedio(e);
- case 5:
- cout << "\nMOSTRAR LISTA" << endl;
- this->lst.Mostrar();
- break;
- }
- case 6:
- cout<<"ORDENAR:";
- string n;
- list<string> L;
- while (cin >> n) {
- L.push_back(n);
- }
- L.sort();
- list<string>::iterator it = L.begin();
- for (; it != L.end(); it++) {
- cout << *it << ' ';
- }
- }
- fecha pedir(){
- fecha fe;
- int d, m, a;
- cout << "\nIngrese feha de nacimiento dd/mm/aa \n\n";
- cout << "Dia: ";
- cin >> d;
- cout << "Mes: ";
- cin >> m;
- cout << "Anyo: ";
- cin >> a;
- fe = fecha(d,m,a);
- return fe;
- }
- estudiantes pedirdato(){
- estudiantes est;
- char Nombre[TAM],Apellido[TAM];
- cout << "\nIngrese su nombre: ";
- cin >> Nombre;
- cout << "\nIngrese su apellido: ";
- cin >> Apellido;
- cout << "\nIngrese Nota1: ";
- cin >> Nota1;
- cout << "\nIngrese Nota2: ";
- cin >>Nota2;
- cout << "\nIngrese Nota3: ";
- cin >> Nota3;
- est = estudiantes(Nombre,Apellido,s);
- return est;
- }
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- (CLASE NODO)
- #ifndef NODO_H
- #define NODO_H
- #include <stdlib.h>
- #include "personas.h"
- class Nodo{
- private:
- estudiantes Valor;
- Nodo *Siguiente;
- public:
- Nodo(estudiantes est=0, Nodo* sig=NULL){
- this->Valor=est;
- this->Siguiente = sig;
- }
- friend class Lista;
- //int getValor(){
- //return this->Valor;
- };typedef Nodo *pnodo;
- #endif
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- (CLASE PERSONAS)
- ifndef PERSONAS_H
- #define PERSONAS_H
- #include "fecha.h"
- #define TAM 10
- #include <String.h>
- class personas{
- private:
- char Nombre [TAM];
- char Apellido [TAM];
- fecha *FechaNac;
- public:
- personas (char N[], char A[], fecha *fn){
- strcpy(this->Nombre,N);
- strcpy(this->Apellido,A);
- this->FechaNac = fn;
- }
- Void MostrarNomAp(){
- cout<<this->Nombre<<" "<<this->Apellido;
- }
- Void MostrarFecha(){
- this->FechaNac->MostrarFecha();
- }
- friend class estudiantes;
- };
- #endif
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- (CLASE ESTUDIANTES)
- #ifndef ESTUDIANTES_H
- #define ESTUDIANTES_H
- #include "personas.h"
- class estudiantes: public personas{
- private:
- float Nota1;
- float Nota2;
- float Nota3;
- float Promedio;
- public:
- estudiantes (char N[], char A[], fecha *fn, float n1, float n2, float n3, float Promedio){
- this->Nota1=n1;
- this->Nota2=n2;
- this->Nota3=n3;
- this->Promedio=(Nota1+Nota2+Nota3)/3;
- float getPromedio(){
- cout << "Promedio: \t" << this->Promedio<< endl;
- return 0;
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement