40 lines
786 B
C++
40 lines
786 B
C++
#include "repository.h"
|
|
#include "domain.h"
|
|
#include <vector>
|
|
#include <algorithm>
|
|
|
|
void test_repository(){
|
|
Repository repository;
|
|
assert(repository.add(Bill("company1","serial1",100,true)) == true);
|
|
assert(repository.add(Bill("company1","serial1",200,false)) == false);
|
|
}
|
|
|
|
Repository::Repository(){
|
|
|
|
}
|
|
|
|
Repository::~Repository(){
|
|
|
|
}
|
|
|
|
bool Repository::add(Bill bill){
|
|
if(std::find(this->_bills.begin(),this->_bills.end(),bill) != this->_bills.end()){
|
|
return false;
|
|
}
|
|
this->_bills.push_back(bill);
|
|
return true;
|
|
}
|
|
|
|
std::vector<Bill>::iterator Repository::begin(){
|
|
return this->_bills.begin();
|
|
}
|
|
|
|
std::vector<Bill>::iterator Repository::end(){
|
|
return this->_bills.end();
|
|
}
|
|
|
|
std::vector<Bill> Repository::bills(){
|
|
return this->_bills;
|
|
}
|
|
|