forked from University/epr24pr5-ojanssen2
Fixed Some CodeQuality
This commit is contained in:
parent
30dfe40ef9
commit
684a321040
6 changed files with 20 additions and 22 deletions
|
@ -16,12 +16,12 @@ namespace models {
|
|||
int get_user_id() const;
|
||||
int get_task_id() const;
|
||||
|
||||
friend ostream& operator<<(ostream& os, const Assignment& t);
|
||||
friend istream& operator>>(istream& is, Assignment& t);
|
||||
friend ostream& operator<<(ostream& os, const Assignment& assignment);
|
||||
friend istream& operator>>(istream& is, Assignment& assignment);
|
||||
};
|
||||
|
||||
ostream& operator<<(ostream& os, const Assignment& t);
|
||||
istream& operator>>(istream& is, Assignment& t);
|
||||
ostream& operator<<(ostream& os, const Assignment& assignment);
|
||||
istream& operator>>(istream& is, Assignment& assignment);
|
||||
}
|
||||
|
||||
#endif // ASSIGNMENT_H
|
||||
|
|
19
Manager.cpp
19
Manager.cpp
|
@ -168,11 +168,12 @@ namespace util {
|
|||
return task_assignments;
|
||||
}
|
||||
|
||||
bool Manager::assignment_exists(int user_id, int task_id) {
|
||||
bool Manager::assignment_exists(const int user_id, const int task_id) const {
|
||||
|
||||
for (Assignment *as: this->assignments)
|
||||
for (Assignment const *as: this->assignments) {
|
||||
if (as->get_user_id() == user_id && as->get_task_id() == task_id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -230,7 +231,7 @@ namespace util {
|
|||
this->tasks.erase(id);
|
||||
}
|
||||
|
||||
void Manager::del_assignment(Assignment &as) {
|
||||
void Manager::del_assignment(Assignment const &as) {
|
||||
if (!this->assignment_exists(as.get_user_id(), as.get_task_id()))
|
||||
throw Error(301, "Eine solche Zuordnung existiert nicht.");
|
||||
int assignment_nr = 0;
|
||||
|
@ -250,20 +251,20 @@ namespace util {
|
|||
throw Error(603, "Datei kann nicht geschrieben werden.");
|
||||
|
||||
out << "[tasks]\n";
|
||||
for (const auto &task_pair: this->tasks)
|
||||
for (const auto &task_pair: this->tasks) {
|
||||
if (task_pair.second)
|
||||
task_pair.second->write(out);
|
||||
|
||||
}
|
||||
out << "\n[users]\n";
|
||||
for (const auto &user_pair: this->users)
|
||||
for (const auto &user_pair: this->users) {
|
||||
if (user_pair.second)
|
||||
user_pair.second->write(out);
|
||||
|
||||
}
|
||||
out << "\n[assignments]\n";
|
||||
for (Assignment *assignment: this->assignments)
|
||||
for (Assignment *assignment: this->assignments) {
|
||||
if (assignment)
|
||||
assignment->write(out);
|
||||
|
||||
}
|
||||
out.close();
|
||||
}
|
||||
} // namespace util
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace util
|
|||
/// @param user_id Die Benutzer-ID.
|
||||
/// @param task_id Die Aufgaben-ID.
|
||||
/// @return Wahr, falls die Zuordnung existiert.
|
||||
bool assignment_exists(int user_id, int task_id);
|
||||
bool assignment_exists(int user_id, int task_id) const;
|
||||
|
||||
/// Fügt einen neuen Benutzer hinzu.
|
||||
/// @param user Ein Zeiger auf den Benutzer.
|
||||
|
@ -123,7 +123,7 @@ namespace util
|
|||
|
||||
/// Löscht eine Zuordnung.
|
||||
/// @param as Die Zuordnung.
|
||||
void del_assignment(Assignment& as);
|
||||
void del_assignment(Assignment const &as);
|
||||
};
|
||||
} // util
|
||||
#endif // ENVIRONMENT_H
|
||||
|
|
9
Task.cpp
9
Task.cpp
|
@ -39,12 +39,11 @@ namespace models
|
|||
*/
|
||||
bool Task::is_active() const {
|
||||
|
||||
Manager* mgr = Manager::get_instance();
|
||||
for (Task* task : mgr->get_tasks()) {
|
||||
for (int child_id : task->get_children()) {
|
||||
const Manager * mgr = Manager::get_instance();
|
||||
for (const Task * task : mgr->get_tasks()) {
|
||||
for (const int child_id : task->get_children()) {
|
||||
// Aktiver Task ist Child von Einem andern Task -> Nicht aktiv
|
||||
if (this->id == child_id) {
|
||||
// cout << this->id << " = " << child_id << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +74,7 @@ namespace models
|
|||
ostream& operator<<(ostream& os, const Task& t)
|
||||
{
|
||||
os << t.get_id() << " %" << t.get_name() << "% %" << t.get_description() << "%";
|
||||
// Fügt Childen Task mit passenden Lehrzeichen hinzu
|
||||
// Fügt Children Task mit passenden Leerzeichen hinzu
|
||||
if (!t.children.empty())
|
||||
os << " ";
|
||||
for (size_t i = 0; i < t.children.size(); ++i)
|
||||
|
|
1
Task.h
1
Task.h
|
@ -25,7 +25,6 @@ namespace models
|
|||
explicit Task(const AddTask& t);
|
||||
|
||||
ostream& write(ostream& stream) const;
|
||||
istream& read(istream&);
|
||||
|
||||
int get_id() const;
|
||||
bool is_active() const;
|
||||
|
|
1
Util.cpp
1
Util.cpp
|
@ -30,7 +30,6 @@ namespace util {
|
|||
}
|
||||
|
||||
vector<int> Util::read_numbers(istream &is) {
|
||||
int i;
|
||||
string until_eol;
|
||||
getline(is, until_eol);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue