diff options
| author | Mitsuo Tokumori <[email protected]> | 2022-12-04 23:13:28 -0500 |
|---|---|---|
| committer | Mitsuo Tokumori <[email protected]> | 2022-12-04 23:13:28 -0500 |
| commit | 8e01ba134a230e47e8b80351dd8abc8c3b72e683 (patch) | |
| tree | 3f0e174c80cc4a6e4a2aa2b5351f4dad66b49d89 /2022-2/L10/mitsuo/Almacen.cpp | |
| parent | ce58d6504665422a0817cf0ddb38fc533d0de33e (diff) | |
| download | LP1-8e01ba134a230e47e8b80351dd8abc8c3b72e683.tar.gz LP1-8e01ba134a230e47e8b80351dd8abc8c3b72e683.tar.bz2 LP1-8e01ba134a230e47e8b80351dd8abc8c3b72e683.zip | |
Add my solution for L10
Diffstat (limited to '2022-2/L10/mitsuo/Almacen.cpp')
| -rw-r--r-- | 2022-2/L10/mitsuo/Almacen.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/2022-2/L10/mitsuo/Almacen.cpp b/2022-2/L10/mitsuo/Almacen.cpp new file mode 100644 index 0000000..07be609 --- /dev/null +++ b/2022-2/L10/mitsuo/Almacen.cpp @@ -0,0 +1,76 @@ +/* + * File: Almacen.cpp + * Author: mitsuo + * + * Created on 02 December 2022, 12:40 + */ + +#include <iostream> +#include <fstream> +#include <iomanip> +#include "Almacen.h" +#include "Marca.h" +#include "Generico.h" + +using namespace std; + +Almacen::Almacen() { +} + +Almacen::Almacen(const Almacen& orig) { +} + +Almacen::~Almacen() { +} + + +void Almacen::carga() { + ifstream f("../medicamentos.csv"); + if (!f) { + cerr << "Error: can't open file medicamentos.csv\n"; + return; + } + + Medicamento * m; + int tipo; // 0: generico, 1: marca + + while (f >> tipo) { + f.get(); + if (tipo == 0) { + m = new Generico(); + } else { + m = new Marca(); + } + m->lee(f); + this->arbolalma.insert(m); +// m->imprime(cout); + } +} + +void Almacen::actualiza() { + /* incrementar precio si codigo en `recarga.csv` y es de marca */ + + ifstream f("../recarga.csv"); + if (!f) { + cerr << "Error: can't open file recarga.csv\n"; + return; + } + this->arbolalma.actualiza(f); +} + +void Almacen::imprime() { + ofstream f("report.txt"); + if (!f) { + cerr << "Error: can't open file report.txt\n"; + return; + } + f << +" REPORTE DE MEDICAMENTOS\n" +"=============================================================================================================\n" +" Codigo Nombre del Medicamento Stock Precio Pais/Laboratorio Lote\n" +"=============================================================================================================\n" +//"94459 VALPROATO DE MAGNESIO SUSP 1980 53.55 ABBOT LABORATORIOS S.A. 1420" + ; + this->arbolalma.print(f); +} + |
