#include "Evento.h" #include Evento::Evento(unsigned tipoEvento) : tipoEvento(tipoEvento) , fecha(0) , duracion(0) , participantes(0) , telefono(0) { } Evento::~Evento() { } void Evento::imprimirOpcionesDeLectura() const { std::cout << "fecha duracion participantes\n" << "lugar\ncontacto\ntelefono"; } std::istream& Evento::leer(std::istream& in) { in >> fecha >> duracion >> participantes; in.ignore(); lugar = leerLinea(in); contacto = leerLinea(in); return in >> telefono; } std::ostream& Evento::imprimir(std::ostream& out) const { return out << fecha << std::endl << duracion << std::endl << participantes << std::endl << lugar << std::endl << contacto << std::endl << telefono << std::endl; } std::string leerLinea(std::istream& in) { const size_t bufferSize = 4096; char* buffer = new char[bufferSize]; in.getline(buffer, bufferSize); std::string result = buffer; delete [] buffer; return result; } // ESTADISTICAS unsigned Evento::totalEventos = 0; unsigned Evento::totalParticipantes = 0; double Evento::totalDuracion = 0; double Evento::totalCosto = 0; void Evento::reiniciarEstadisticas() { totalEventos = 0; totalParticipantes = 0; totalDuracion = 0; totalCosto = 0; } void Evento::actualizarEstadisticas() const { ++totalEventos; totalParticipantes += participantes; totalDuracion += duracion; totalCosto += calcularCosto(); } void Evento::imprimirEstadisticas() { std::cout << "EVENTOS:\n" << totalEventos << " eventos en total\n"; if ( totalEventos > 0 ) std::cout << std::fixed << std::setprecision(2) << totalDuracion / totalEventos << " horas promedio por evento\n" << totalParticipantes / totalEventos << " participantes promedio por evento\n" << std::setprecision(0) << totalCosto / totalEventos << " colones de costo promedio por evento\n" << totalCosto << " colones de costo total de todos los eventos\n"; }