summaryrefslogtreecommitdiff
path: root/1p6.cpp
blob: 71dfd285025f64ab52d92133f588c180c1994134 (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
#include <iostream>
#include "sales_item.hpp"

/*
 *
 * 1.6 example
 *
 *
 */

int main () {

	Sales_item Total;
	Sales_item Trans;
	if(std::cin >> Total) {
		while(std::cin >> Trans) {
			if(Trans.isbn() == Total.isbn()) {
				Total += Trans;
			} else {
				std::cout << Total << std::endl;
				Total = Trans;
			}
		}
		
		std::cout << Total << std::endl;
	} else {
		std::cerr << "Error" << std::endl;
		return -1;
	}
	
	return 0;
}