This commit is contained in:
Diego González Prieto 2023-08-21 10:58:17 -03:00
commit d4ffae872b
13 changed files with 737 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/bin
/obj

48
claseReunion.cbp Normal file
View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="claseReunion" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/claseReunion" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
<Add directory="include" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/claseReunion" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
<Add directory="include" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="include/Fecha.h" />
<Unit filename="include/Horario.h" />
<Unit filename="include/Persona.h" />
<Unit filename="include/Reunion.h" />
<Unit filename="main.cpp" />
<Unit filename="src/Fecha.cpp" />
<Unit filename="src/Horario.cpp" />
<Unit filename="src/Persona.cpp" />
<Unit filename="src/Reunion.cpp" />
<Extensions />
</Project>
</CodeBlocks_project_file>

38
claseReunion.depend Normal file
View File

@ -0,0 +1,38 @@
# depslib dependency file v1.0
1692625716 source:/home/di3/Documentos/facu-estudios-formaciones/TUP/Cursada/1A2C/LAB_2/src/claseReunion/main.cpp
<iostream>
"Reunion.h"
1692572259 source:/home/di3/Documentos/facu-estudios-formaciones/TUP/Cursada/1A2C/LAB_2/src/claseReunion/src/Fecha.cpp
<iostream>
<cmath>
<ctime>
"Fecha.h"
1692568843 /home/di3/Documentos/facu-estudios-formaciones/TUP/Cursada/1A2C/LAB_2/src/claseReunion/include/Fecha.h
<cstring>
1692624831 source:/home/di3/Documentos/facu-estudios-formaciones/TUP/Cursada/1A2C/LAB_2/src/claseReunion/src/Horario.cpp
<iostream>
<ctime>
"Horario.h"
1692624831 /home/di3/Documentos/facu-estudios-formaciones/TUP/Cursada/1A2C/LAB_2/src/claseReunion/include/Horario.h
1692625732 source:/home/di3/Documentos/facu-estudios-formaciones/TUP/Cursada/1A2C/LAB_2/src/claseReunion/src/Reunion.cpp
<iostream>
"Reunion.h"
1692625709 /home/di3/Documentos/facu-estudios-formaciones/TUP/Cursada/1A2C/LAB_2/src/claseReunion/include/Reunion.h
<cstring>
"Persona.h"
"Fecha.h"
"Horario.h"
1692568668 source:/home/di3/Documentos/facu-estudios-formaciones/TUP/Cursada/1A2C/LAB_2/src/claseReunion/src/Persona.cpp
<iostream>
"Persona.h"
1692548660 /home/di3/Documentos/facu-estudios-formaciones/TUP/Cursada/1A2C/LAB_2/src/claseReunion/include/Persona.h
<string>

50
claseReunion.layout Normal file
View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="src/Horario.cpp" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="994" topLine="7" />
</Cursor>
</File>
<File name="include/Reunion.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="289" topLine="0" />
</Cursor>
</File>
<File name="include/Horario.h" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="315" topLine="0" />
</Cursor>
</File>
<File name="src/Persona.cpp" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="121" topLine="0" />
</Cursor>
</File>
<File name="include/Persona.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="349" topLine="0" />
</Cursor>
</File>
<File name="include/Fecha.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="484" topLine="0" />
</Cursor>
</File>
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="442" topLine="0" />
</Cursor>
</File>
<File name="src/Reunion.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1050" topLine="27" />
</Cursor>
</File>
<File name="src/Fecha.cpp" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="865" topLine="41" />
</Cursor>
</File>
</CodeBlocks_layout_file>

35
include/Fecha.h Normal file
View File

@ -0,0 +1,35 @@
#ifndef FECHA_H
#define FECHA_H
#include <cstring>
class Fecha
{
public:
Fecha();
Fecha(int dia, int mes, int anio);
virtual ~Fecha();
int getDia();
int getMes();
int getAnio();
void setDia(int);
void setMes(int);
void setAnio(int);
std::string toString();
static bool esAnioBisiesto(int anio);
bool esAnioBisiesto();
static bool esFechaValida(int dia, int mes, int anio);
bool esFechaValida();
void agregarDias(int dias);
protected:
private:
int _dia;
int _mes;
int _anio;
void agregarDia();
void restarDia();
};
#endif // FECHA_H

26
include/Horario.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef HORARIO_H
#define HORARIO_H
class Horario
{
public:
Horario();
Horario(int horas, int minutos, int segundos);
virtual ~Horario();
int getHoras();
int getMinutos();
int getSegundos();
void setHoras(int horas);
void setMinutos(int minutos);
void setSegundos(int segundos);
std::string toString();
protected:
private:
int _horas;
int _minutos;
int _segundos;
};
#endif // HORARIO_H

24
include/Persona.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef PERSONA_H
#define PERSONA_H
#include <string>
class Persona
{
public:
Persona();
Persona(std::string nombre, std::string apellido);
virtual ~Persona();
std::string getNombre();
std::string getApellido();
void setNombre(std::string nombre);
void setApellido(std::string apellido);
std::string toString();
protected:
private:
std::string _nombre;
std::string _apellido;
};
#endif // PERSONA_H

43
include/Reunion.h Normal file
View File

@ -0,0 +1,43 @@
#ifndef REUNION_H
#define REUNION_H
#include <cstring>
#include "Persona.h"
#include "Fecha.h"
#include "Horario.h"
class Reunion
{
public:
Reunion();
virtual ~Reunion();
void setFecha(Fecha fecha);
void setHorario(Horario horario);
void setLugar(std::string lugar);
void setTema(std::string tema);
void setDuracion(int duracion);
void setIntegrantes(Persona *integrantes);
std::string getLugar();
std::string getTema();
int getDuracion();
void getIntegrantes(Persona *integrantes);
Persona *getIntegrantes();
Fecha getFecha();
Horario getHorario();
int agregarIntegrante(Persona p);
Persona getIntegrante(int posicion);
int getCantidadIntegrantes();
protected:
private:
Fecha _fecha;
Horario _horario;
std::string _lugar, _tema;
int _duracion=0;
Persona _integrantes[5];
};
#endif // REUNION_H

91
main.cpp Normal file
View File

@ -0,0 +1,91 @@
#include <iostream>
#include "Reunion.h"
using namespace std;
int main()
{
Reunion r[6];
Persona brian("Brian", "Lara"), angel("Angel", "Simon"), maxiW("Maxi", "Wenner"), laura("Laura", "Velez"), maxiS("Maxi", "Sar");
r[0].setFecha(Fecha(1, 10, 2023));
r[0].setHorario(Horario(19,0,0));
r[0].setLugar("Buenos Aires");
r[0].setTema("Programación en C++");
r[0].setDuracion(90);
Persona integrantes1[5] = {brian, angel};
r[0].setIntegrantes(integrantes1);
r[1].setFecha(Fecha(1, 4, 2023));
r[1].setHorario(Horario(19,0,0));
r[1].setLugar("Internet");
r[1].setTema("Estadística y Programación");
r[1].setDuracion(100);
r[1].agregarIntegrante(maxiW);
r[2].setFecha(Fecha(20, 11, 2023));
r[2].setHorario(Horario(23,0,0));
r[2].setLugar("Discord");
r[2].setTema("Goto Gamejam 2023");
r[2].setDuracion(0);
r[2].agregarIntegrante(brian);
r[3].setFecha(Fecha(1, 3, 2024));
r[3].setHorario(Horario(18,0,0));
r[3].setLugar("Buenos Aires");
r[3].setTema("Bases de Datos con SQL");
r[3].setDuracion(60);
Persona integrantes2[5] = {laura, angel};
r[3].setIntegrantes(integrantes2);
r[4].setFecha(Fecha(1, 10, 2023));
r[4].setHorario(Horario(18,0,0));
r[4].setLugar("Discord");
r[4].setTema("C#");
r[4].setDuracion(50);
r[4].agregarIntegrante(maxiS);
r[5].setFecha(Fecha(5, 11, 2023));
r[5].setHorario(Horario(21,0,0));
r[5].setLugar("Steam");
r[5].setTema("Torneo de Age of Empires");
r[5].setDuracion(80);
Persona integrantes3[5] = {brian, angel, maxiS, maxiW};
r[5].setIntegrantes(integrantes3);
int maxDur = 0;
int pos;
for (int i=0;i<6;i++)
{
if (r[i].getDuracion() > maxDur)
{
maxDur = r[i].getDuracion();
pos = i;
}
}
cout << "Integrantes de la reunión más larga:\n";
for (int i=0; i < 5; i++)
{
if (r[pos].getIntegrantes()[i].toString() != " ") cout << r[pos].getIntegrantes()[i].toString() << endl;
}
cout << "\nTemas de las reuniones del 2023:\n";
for (int i=0; i < 6; i++)
{
if (r[i].getFecha().getAnio() == 2023 ) cout << r[i].getTema() << endl;
}
cout << "\nTemas de las reuniones del 2024:\n";
for (int i=0; i < 6; i++)
{
if (r[i].getFecha().getAnio() == 2024) cout << r[i].getTema() << endl;
}
cout << "\nCantidad de reuniones después de las 20hs:\n";
int cant=0;
for (int i=0; i < 6; i++)
{
if (r[i].getHorario().getHoras() > 20 ) cant++;
}
cout << cant << endl;
return 0;
}

173
src/Fecha.cpp Normal file
View File

@ -0,0 +1,173 @@
#include <iostream>
#include <cmath>
#include <ctime>
using namespace std;
#include "Fecha.h"
Fecha::Fecha()
{
std::time_t now = std::time(NULL);
std::tm * local_time = std::localtime(&now);
_anio = local_time->tm_year + 1900;
_mes = local_time->tm_mon + 1;
_dia = local_time->tm_mday;
}
Fecha::Fecha(int dia, int mes, int anio)
{
if (!Fecha::esFechaValida(dia, mes, anio))
{
setDia(1);
setMes(1);
setAnio(2023);
return;
}
setDia(dia);
setMes(mes);
setAnio(anio);
}
Fecha::~Fecha()
{
//dtor
}
int Fecha::getDia()
{
return _dia;
}
int Fecha::getMes()
{
return _mes;
}
int Fecha::getAnio()
{
return _anio;
};
void Fecha::setDia(int d)
{
_dia = d;
}
void Fecha::setMes(int m)
{
_mes = m;
}
void Fecha::setAnio(int a)
{
_anio = a;
};
string Fecha::toString()
{
string d = getDia() >=10 ? to_string(getDia()) : "0" + to_string(getDia());
string m = getMes() >=10 ? to_string(getMes()) : "0" + to_string(getMes());
string a;
int anio = getAnio();
if (anio >= 1000)
{
a = to_string(getAnio());
}
else if (anio < 100)
{
a = "00" + to_string(getAnio());
}
else if (anio < 10)
{
a = "000" + to_string(getAnio());
}
else
{
a = "0" + to_string(getAnio());
}
return d + "/" + m + "/" + a;
}
bool Fecha::esAnioBisiesto(int anio)
{
if (anio % 4 != 0) return false;
if (anio % 100 == 0 && anio % 400 != 0) return false;
return true;
}
bool Fecha::esAnioBisiesto()
{
return esAnioBisiesto(getAnio());
}
bool Fecha::esFechaValida(int dia, int mes, int anio)
{
if (dia < 1 || dia > 31 || mes < 1 || mes > 12 || anio < 1 || anio > 9999) return false;
bool bisiesto = esAnioBisiesto(anio);
switch (mes)
{
case 2:
if (bisiesto && dia <= 29) return true;
return dia <= 28;
break;
case 4:
case 6:
case 9:
case 11:
return dia <= 30;
break;
default:
return true;
}
}
bool Fecha::esFechaValida()
{
return esFechaValida(getDia(), getMes(), getAnio());
}
void Fecha::agregarDia()
{
setDia(getDia()+1);
if (esFechaValida()) return;
setDia(1);
setMes(getMes()+1);
if (esFechaValida()) return;
setMes(1);
setAnio(getAnio()+1);
}
void Fecha::restarDia()
{
if (getDia() != 1)
{
setDia(getDia()-1);
return;
}
if (getMes() == 1)
{
setAnio(getAnio()-1);
setMes(12);
setDia(31);
return;
}
setMes(getMes()-1);
setDia(31);
while (!esFechaValida()) setDia(getDia()-1);
}
void Fecha::agregarDias(int dias)
{
if (dias == 0) return;
bool agregar = dias > 0;
int cant = abs(dias);
{
for (int i=0; i< cant; i++)
{
if (agregar)
{
agregarDia();
continue;
}
restarDia();
}
}
}

67
src/Horario.cpp Normal file
View File

@ -0,0 +1,67 @@
#include <iostream>
using namespace std;
#include <ctime>
#include "Horario.h"
Horario::Horario()
{
std::time_t now = std::time(NULL);
std::tm * local_time = std::localtime(&now);
_horas = local_time->tm_hour;
_minutos = local_time->tm_min;
_segundos = local_time->tm_sec;
}
Horario::Horario(int horas, int minutos, int segundos)
{
if (horas > 23 || horas < 0 || minutos > 59 || minutos < 0 || segundos > 59 || segundos < 0)
{
std::time_t now = std::time(NULL);
std::tm * local_time = std::localtime(&now);
_horas = local_time->tm_hour;
_minutos = local_time->tm_min;
_segundos = local_time->tm_sec;
return;
}
_horas = horas;
_minutos = minutos;
_segundos = segundos;
}
Horario::~Horario()
{
//dtor
}
int Horario::getHoras()
{
return _horas;
}
int Horario::getMinutos()
{
return _minutos;
}
int Horario::getSegundos()
{
return _segundos;
}
void Horario::setHoras(int horas)
{
_horas = horas;
}
void Horario::setMinutos(int minutos)
{
_minutos = minutos;
}
void Horario::setSegundos(int segundos)
{
_segundos = segundos;
}
string Horario::toString()
{
string h = getHoras() >=10 ? to_string(getHoras()) : "0" + to_string(getHoras());
string m = getMinutos() >=10 ? to_string(getMinutos()) : "0" + to_string(getMinutos());
string s = getSegundos() >=10 ? to_string(getSegundos()) : "0" + to_string(getSegundos());
return h + ":" + m + ":" + s;
}

43
src/Persona.cpp Normal file
View File

@ -0,0 +1,43 @@
#include <iostream>
using namespace std;
#include "Persona.h"
Persona::Persona()
{
setNombre("");
setApellido("");
}
Persona::Persona(string nombre, string apellido)
{
setNombre(nombre);
setApellido(apellido);
}
Persona::~Persona()
{
//dtor
}
string Persona::getNombre()
{
return _nombre;
}
string Persona::getApellido()
{
return _apellido;
}
void Persona::setNombre(string nombre)
{
if (nombre != "") _nombre = nombre;
}
void Persona::setApellido(string apellido)
{
if (apellido != "") _apellido = apellido;
}
string Persona::toString()
{
return getNombre() + " " + getApellido();
}

96
src/Reunion.cpp Normal file
View File

@ -0,0 +1,96 @@
#include <iostream>
using namespace std;
#include "Reunion.h"
Reunion::Reunion()
{
//ctor
}
Reunion::~Reunion()
{
//dtor
}
void Reunion::setIntegrantes(Persona *integrantes)
{
for (int i=0; i < 5; i++) _integrantes[i] = integrantes[i];
}
Persona *Reunion::getIntegrantes()
{
return _integrantes;
}
void Reunion::setFecha(Fecha fecha)
{
_fecha = fecha;
}
Fecha Reunion::getFecha()
{
return _fecha;
}
int Reunion::agregarIntegrante(Persona p)
{
Persona *integrantes;
integrantes = getIntegrantes();
for (int i=0; i < 5; i++)
{
if (integrantes[i].toString() == " ")
{
integrantes[i] = p;
return i;
}
}
return -1;
}
Persona Reunion::getIntegrante(int posicion)
{
return getIntegrantes()[posicion];
}
int Reunion::getCantidadIntegrantes()
{
int cant = 0;
for (int i=0; i<5;i++)
{
if (getIntegrante(i).toString() == " ") return cant;
cant++;
}
}
Horario Reunion::getHorario(){
return _horario;
}
void Reunion::setHorario(Horario horario)
{
_horario = horario;
}
void Reunion::setLugar(std::string lugar)
{
_lugar = lugar;
}
void Reunion::setTema(std::string tema)
{
_tema = tema;
}
void Reunion::setDuracion(int duracion)
{
_duracion = duracion;
}
std::string Reunion::getLugar()
{
return _lugar;
}
std::string Reunion::getTema()
{
return _tema;
}
int Reunion::getDuracion()
{
return _duracion;
}