From 8e01ba134a230e47e8b80351dd8abc8c3b72e683 Mon Sep 17 00:00:00 2001 From: Mitsuo Tokumori Date: Sun, 4 Dec 2022 23:13:28 -0500 Subject: Add my solution for L10 --- 2022-2/L10/mitsuo/Marca.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 2022-2/L10/mitsuo/Marca.cpp (limited to '2022-2/L10/mitsuo/Marca.cpp') diff --git a/2022-2/L10/mitsuo/Marca.cpp b/2022-2/L10/mitsuo/Marca.cpp new file mode 100644 index 0000000..25907fe --- /dev/null +++ b/2022-2/L10/mitsuo/Marca.cpp @@ -0,0 +1,51 @@ +/* + * File: Marca.cpp + * Author: mitsuo + * + * Created on 02 December 2022, 12:36 + */ + +#include +#include +#include "Marca.h" +#include "aux.h" + +using namespace std; + +Marca::Marca() { + this->laboratorio = new char [MAXLEN]; +} + +Marca::Marca(const Marca& orig) { +} + +Marca::~Marca() { + delete [] this->laboratorio; +} + +int Marca::lee(std::istream &input) { + this->Medicamento::lee(input); + input.getline(this->laboratorio, MAXLEN, ','); + input >> this->lote; + + return !input.eof(); +} + +void Marca::imprime(std::ostream &output) { + this->Medicamento::imprime(output); + output << WL(40) << this->laboratorio; + output << WL(8) << this->lote; + output << '\n'; +} + +void Marca::actualiza(std::istream &input) { + input.clear(); + input.seekg(0); // rewind + + int codigo; + while (input >> codigo) { + if (codigo == this->getCodigo()) { + this->setPrecio(this->getPrecio() * 1.2); + } + } +} -- cgit v1.2.3