Skip to content

Instantly share code, notes, and snippets.

@leopic
Created December 9, 2012 22:40
Show Gist options
  • Save leopic/4247325 to your computer and use it in GitHub Desktop.
Save leopic/4247325 to your computer and use it in GitHub Desktop.
Index: Arbol.cpp
===================================================================
--- Arbol.cpp (revision 30)
+++ Arbol.cpp (working copy)
@@ -2,6 +2,7 @@
#include "Nodo.h"
#include <iostream>
+#include <cstddef>
//#include <assert.h>
using namespace std;
@@ -86,7 +87,7 @@
//Cuando tiene 2 sub-árboles
}else if(pNodo->obtenerHijoDerecho() != NULL && pNodo->obtenerHijoIzquierdo() != NULL){
temp = pNodo->obtenerHijoDerecho(); //temp se convierte en el hijo derecho del nodo a borrar
- while ( !temp->obtenerHijoIzquierdo() == NULL ){//Mientras que el nodo tenga hijo izquierdo
+ while ( temp->obtenerHijoIzquierdo() != NULL ){//Mientras que el nodo tenga hijo izquierdo
temp = temp->obtenerHijoIzquierdo();//nodo = a su hijo izquierdo e itera...
//Entonces el nodo "temp" es el que tiene el menor valor de todo el subarbol derecho
}
Index: UI.h
===================================================================
--- UI.h (revision 30)
+++ UI.h (working copy)
@@ -1,31 +1,32 @@
#ifndef UI_H
#define UI_H
-#include <string>
#include "Arbol.h"
+#include "Documento.h"
#include "Nodo.h"
-#include "Documento.h"
+#include <string>
using namespace std;
-class UI
-{
- private:
- Arbol _arbol;
- Nodo * tempNodo;
- Documento * tempDoc;
- tm fecha;
- public:
- UI();
- string MenuPrincipal();
- void valoresInicio();
- void MenuPrincipalSeleccion(int pOpcion);
- void MenuNuevoDocumento();
- void MenuBuscarDocumento();
- void MenuDocumento();
- /*void MenuNuevaPregunta();
- void MenuBuscarPregunta();
- void MenuEliminarPregunta();*/
-}
+class UI {
+ private:
+ Arbol _arbol;
+ Nodo * tempNodo;
+ Documento * tempDoc;
+ tm fecha;
-#endif
\ No newline at end of file
+ public:
+ UI();
+ string MenuPrincipal();
+ void valoresInicio();
+ void MenuPrincipalSeleccion(int pOpcion);
+ void MenuNuevoDocumento();
+ void MenuBuscarDocumento();
+ void MenuDocumento();
+ /*void MenuNuevaPregunta();
+ void MenuBuscarPregunta();
+ void MenuEliminarPregunta();*/
+};
+
+#endif
+
Index: Main.cpp
===================================================================
--- Main.cpp (revision 30)
+++ Main.cpp (working copy)
@@ -1,30 +1,25 @@
-//#include <cstdlib>
-
+#include "UI.cpp"
+// TODO: LEO
+#include <conio.h>
#include <iostream>
#include <stdio.h>
-
-#include <conio.h>
#include <string>
-#include "UI.h"
-;using namespace std;
+int main (int arg, char *argv[]) {
+ int mult, num;
+ UI uiMenu;
-int main (int arg, char *argv[])
-{
- int mult, num;
- UI uiMenu;
-
- do{
- uiMenu.valoresInicio();
- cout << uiMenu.MenuPrincipal();
- cin >> num;
- uiMenu.MenuPrincipalSeleccion(num);
- }while(num != 3);
+ do {
+ uiMenu.valoresInicio();
+ cout << uiMenu.MenuPrincipal();
+ cin >> num;
+ uiMenu.MenuPrincipalSeleccion(num);
+ } while(num != 3);
- system("PAUSE");
- return EXIT_SUCCESS;
+ // TODO: LEO
+ //std::cin.get();
+ //return 0;
+ system("PAUSE");
+ return EXIT_SUCCESS;
}
-
-
-
Index: Documento.cpp
===================================================================
--- Documento.cpp (revision 30)
+++ Documento.cpp (working copy)
@@ -2,8 +2,6 @@
#include <string>
#include <sstream>
-using namespace std;
-
// Constructor vacio
Documento::Documento() {};
@@ -71,8 +69,8 @@
concatenador << "%------%" << endl
<< "Nombre: " << nombre << endl
<< "Autor: " << autor << endl
- << "ISBN: " << isbn << endl;
- //<< "Publicación: " << obtenerFechaPublicacion() << endl;
+ << "ISBN: " << isbn << endl
+ << "Publicación: " << obtenerFechaPublicacion() << endl;
return concatenador.str();
}
Index: UI.cpp
===================================================================
--- UI.cpp (revision 30)
+++ UI.cpp (working copy)
@@ -1,15 +1,20 @@
#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
#include <string>
+#include <time.h>
+
+#include "Arbol.cpp"
+#include "Documento.cpp"
+#include "Nodo.cpp"
#include "UI.h"
-#include "Arbol.h"
-#include "Nodo.h"
-#include "Documento.h"
-#include <time.h>
+using namespace std;
-;using namespace std;
+// Constructor vacio
+UI::UI() { }
-void UI::valoresInicio(){
+void UI::valoresInicio() {
tempDoc = new Documento("Pablo", fecha, "123456789", "Documento1");
tempNodo = new Nodo(tempDoc);
tempNodo->setPeso(21);
@@ -61,7 +66,6 @@
_arbol.insertarNodo(tempNodo);
//
}
-UI::UI(){}
string UI::MenuPrincipal(){
string res = "\n***** Menu inicio ***** \n";
@@ -86,11 +90,16 @@
void UI::MenuNuevoDocumento(){
string nombre;
int tipoInt;
+ int mes;
+ int dia;
+ int ano;
string autor;
string isbn;
double ft;
double fd;
double N;
+ tm fecha;
+
cout << "\n***** Crear Documento ***** \n";
cout << "Ingresar Nombre: \n";
cin >> nombre;
@@ -98,12 +107,24 @@
cin >> autor;
cout << "Ingresar ISBN: \n";
cin >> isbn;
+ cout << "Ingresar dia de publicacion: \n";
+ cin >> dia;
+ cout << "Ingresar mes de publicacion: \n";
+ cin >> mes;
+ cout << "Ingresar anyo de publicacion: \n";
+ cin >> ano;
cout << "Ingresar ft: \n";
cin >> ft;
cout << "Ingresar fd: \n";
cin >> fd;
cout << "Ingresar fN: \n";
cin >> N;
+
+ ano = ano - 1900;
+ fecha.tm_year = ano;
+ fecha.tm_mon = mes;
+ fecha.tm_mday = dia;
+
tempDoc = new Documento(autor, fecha, isbn, nombre);
tempNodo = new Nodo(tempDoc);
tempNodo->calcularPeso(ft, fd, N);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment