diff options
| author | Mitsuo Tokumori <[email protected]> | 2022-09-09 19:18:52 -0500 |
|---|---|---|
| committer | Mitsuo Tokumori <[email protected]> | 2022-09-09 19:18:52 -0500 |
| commit | 1ac847532f673a66e790b05c8aef22fc959ddd19 (patch) | |
| tree | 96a3e1ef2b6d35cb1539ea559d44f1c27fab6281 /2022-2/L1/mitsuo/fun.cpp | |
| download | LP1-1ac847532f673a66e790b05c8aef22fc959ddd19.tar.gz LP1-1ac847532f673a66e790b05c8aef22fc959ddd19.tar.bz2 LP1-1ac847532f673a66e790b05c8aef22fc959ddd19.zip | |
2022-2 L1 mostly done.
See TODO in fun.cpp
Diffstat (limited to '2022-2/L1/mitsuo/fun.cpp')
| -rw-r--r-- | 2022-2/L1/mitsuo/fun.cpp | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/2022-2/L1/mitsuo/fun.cpp b/2022-2/L1/mitsuo/fun.cpp new file mode 100644 index 0000000..5966472 --- /dev/null +++ b/2022-2/L1/mitsuo/fun.cpp @@ -0,0 +1,113 @@ +/* Functions are written in the in order as I implement them. + * "DiseƱo desendente" */ + +#include <iostream> +#include <iomanip> +#include <cstring> // strcmp + +#include "fun.h" + +using namespace std; + +void readRecordsWriteReport() +{ + char esp1[MAXLEN], esp2[MAXLEN], strfecha[MAXLEN]; + + // Header + cin >> esp1 >> esp2 >> strfecha; + writeHeader(esp1, esp2, strfecha); + + // Medicos + readWriteMedicos(); +} + +void writeHeader(char *esp1, char *esp2, char *strfecha) +{ + cout << +" EMPRESA PRESTADORA DE SALUD\n" +"================================================================================\n" +"ESPECIALIDADES A VERIFICAR: " << esp1 << " Y " << esp2 << '\n' << +"FECHA DEL PROCESO: " << strfecha << '\n' << +"================================================================================\n" + ; + // Note: formatting strfecha to (dd/mm/yyyy) is a lot of work for little + // benefit. Do later. +} + +void readWriteMedicos() +{ + char id[MAXLEN], name[MAXLEN]; + while (cin >> id >> name) { + //cout << "Medico: " << id << name << '\n'; + writeformattedMedico(id, name); + + // Pacientes + readWritePacientes(); + } +} + +void readWritePacientes() +{ + /* The trick here is that every Paciente begins with a number. So input + * will fail when there is no more Pacientes. Then clear the fail flag to + * resume with next Medico */ + char name[MAXLEN]; + int dni, qty; + while (cin >> dni >> name >> qty) { + //cout << " Paciente: " << dni << name << qty << '\n'; + writeformattedPaciente(10, dni, name); + + // Medicina + readWriteMedicinas(qty); + } + cin.clear(); +} + +void readWriteMedicinas(int n) +{ + char name[MAXLEN], strfecha[MAXLEN]; + int id; + while (n--) { + cin >> id >> name >> strfecha; + + //cout << " Medicina: " << id << name << strfecha << '\n'; + writeformattedMedicina(2, id, name, strfecha, n); + } +} + +// Una vez con los datos leidos. Verificando que el ultimo medico y medicina se +// leen bien. Se procede a tratar de formatear bien la salida. + +void writeformattedMedico(char *id, char *name) +{ + char esp[MAXLEN] = "Ginecologia"; + cout << +"Medico: " << name << "[" << id << "] Especialidad: " << esp << '\n' << +"--------------------------------------------------------------------------------\n" +" Pacientes atendidos Mediciinas recibidas\n" +"--------------------------------------------------------------------------------\n" +" DNI Nombre Cantidad Codigo Descripcion FV Obs. \n" +"--------------------------------------------------------------------------------\n" + ; +} + +void writeformattedPaciente(int i, int id, char *name) +{ + cout << i << ") " << id << " " << name << " "; +} + +void writeformattedMedicina(int i, int id, char *name, char *strfecha, int qty) +{ + char obs[MAXLEN] = "VENCIDO"; + + if (i != 0) { + cout << +" "; + } else { + cout << qty << " "; + } + + cout << id << " " << name << " " << strfecha << " " << obs << '\n'; +} + +// TODO: formatting + resumen |
