forked from University/epr24pr5-ojanssen2
41 lines
1 KiB
C++
41 lines
1 KiB
C++
#include "Assignment.h"
|
|
#include "Error.h"
|
|
|
|
using err::Error;
|
|
|
|
namespace models {
|
|
Assignment::Assignment(const int& user_id, const int& task_id) : user_id(user_id), task_id(task_id) {}
|
|
Assignment::Assignment(): user_id(0), task_id(0) {}
|
|
|
|
ostream& Assignment::write(ostream& stream) const
|
|
{
|
|
stream << *this;
|
|
return stream;
|
|
}
|
|
|
|
int Assignment::get_task_id() const {
|
|
return this->task_id;
|
|
}
|
|
|
|
int Assignment::get_user_id() const {
|
|
return this->user_id;
|
|
}
|
|
|
|
ostream& operator<<(ostream& os, const Assignment& t) {
|
|
os << t.get_user_id() << " " << t.get_task_id() << "\n";
|
|
return os;
|
|
}
|
|
|
|
istream& operator>>(istream& is, Assignment& t) {
|
|
int user_id;
|
|
is >> user_id;
|
|
if (!is)
|
|
throw Error(602, "Datei hat ein unbekanntes Format.");
|
|
int task_id;
|
|
is >> task_id;
|
|
if (!is)
|
|
throw Error(602, "Datei hat ein unbekanntes Format.");
|
|
t = {user_id, task_id};
|
|
return is;
|
|
}
|
|
} // models
|