summaryrefslogtreecommitdiffstats
path: root/2022-2/L10/mitsuo/Medicamento.cpp
blob: 7ab0da2203836456a7c1d78ae55b91c8cb84c013 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* 
 * File:   Medicamento.cpp
 * Author: mitsuo
 * 
 * Created on 02 December 2022, 12:31
 */

#include <iostream>
#include <iomanip>
#include "Medicamento.h"
#include "aux.h"

using namespace std;

Medicamento::Medicamento() {
    this->codigo = -1;
    this->nombre = new char [MAXLEN];
}

Medicamento::Medicamento(const Medicamento& orig) {
}

Medicamento::~Medicamento() {
    delete [] this->nombre;
}

void Medicamento::setPrecio(double precio) {
    this->precio = precio;
}

double Medicamento::getPrecio() const {
    return precio;
}

int Medicamento::getCodigo() const {
    return codigo;
}

int Medicamento::lee(std::istream &input) {
    char c;
    input >> this->codigo >> c;
    input.getline(this->nombre, MAXLEN, ',');
    input >> this->stock >> c;
    input >> this->precio >> c;
    
//    char s[MAXLEN];
//    input.getline(s, MAXLEN);
    
    return !input.eof();
}

void Medicamento::imprime(std::ostream &output) {
    output << WL(8) << this->codigo;
    output << WL(40) << this->nombre;
    output << WR(8) << this->stock;
    output << WR(8) << this->precio;
//    output << '\n';
}


void Medicamento::actualiza(std::istream &input) {
    
}