School Commit Init
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
#include "domain.h"
|
||||
#include "repository.h"
|
||||
#include "controller.h"
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
|
||||
Controller::Controller(){
|
||||
|
||||
}
|
||||
|
||||
Controller::~Controller(){
|
||||
|
||||
}
|
||||
|
||||
bool Controller::add(char* company_name,char* serial_number,int sum,bool isPaid){
|
||||
return this->_repository.add(Bill(company_name,serial_number,sum,isPaid));
|
||||
}
|
||||
|
||||
std::vector<Bill>::iterator Controller::begin(){
|
||||
return this->_repository.begin();
|
||||
}
|
||||
|
||||
std::vector<Bill>::iterator Controller::end(){
|
||||
return this->_repository.end();
|
||||
}
|
||||
|
||||
std::vector<Bill> Controller::getBills(){
|
||||
std::vector<Bill> copy_bills = this->_repository.bills();
|
||||
std::sort(copy_bills.begin(),copy_bills.end(),[](Bill bill1,Bill bill2){return strcmp(bill1.company_name(),bill2.company_name()) <= 0;});
|
||||
return copy_bills;
|
||||
}
|
||||
|
||||
std::vector<Bill> Controller::getPaidBills(){
|
||||
std::vector<Bill> copy_bills = this->_repository.bills();
|
||||
std::vector<Bill> paid_bills(copy_bills.size());
|
||||
auto it = std::copy_if(copy_bills.begin(),copy_bills.end(),paid_bills.begin(),[](Bill bill){return bill.isPaid();});
|
||||
paid_bills.resize(std::distance(paid_bills.begin(),it));
|
||||
return paid_bills;
|
||||
}
|
||||
Reference in New Issue
Block a user