Skip to content

Commit

Permalink
Merge Rendoirbranch
Browse files Browse the repository at this point in the history
Rendoirbranch
  • Loading branch information
myownxdeath authored Nov 16, 2016
2 parents ab42215 + d0ddccd commit 22b52a8
Show file tree
Hide file tree
Showing 27 changed files with 1,723 additions and 146 deletions.
21 changes: 21 additions & 0 deletions College.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#pragma once

#include "University.h"
#include "College.h"
#include "Utilities.h"


College::College(string n, string a, University* u): name(n), acronym(a), university(u) {
u->addCollege(this);
}

void College::addCourse(Course* c)
{
Expand All @@ -20,4 +27,18 @@ bool College::removeCourse(Course* c)
}
}
return false;
}

bool compareCollegeByName(College* c1, College* c2)
{
return c1->name < c2->name;
}

ostream& operator<<(ostream& os, College const &c)
{
os << c.getName()
<< setw(CONSOLE_WIDTH * 1.5 - c.getName().size())
<< c.getAcronym()
<< endl;
return os;
}
18 changes: 10 additions & 8 deletions College.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
#ifndef COLLEGE_H
#define COLLEGE_H

//#include <string>
//#include <vector>

#include <string>
#include <vector>
using namespace std;

#include "University.h"

class Course;
class University;

class College
{
Expand All @@ -21,7 +19,7 @@ class College

public:
//MEMBER FUNCTIONS
College(string n, string a, University* u) : name(n), acronym(a), university(u) {}
College(string n, string a, University* u);
void addCourse(Course* c);
bool removeCourse(Course* c);

Expand All @@ -31,8 +29,12 @@ class College
vector<Course*> getCourses() const { return courses; }
University* getUniversity() const { return university; }



//COMPARES
friend bool compareCollegeByName(College* c1, College* c2);

//OPERATORS
friend ostream& operator<<(ostream& os, College const &c);

};

#endif
6 changes: 4 additions & 2 deletions CollegeUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#ifndef COLLEGEUSER_H
#define COLLEGEUSER_H

//#include <string>
#include <string>
#include "Date.h"
#include "College.h"
using namespace std;

class College;

class CollegeUser
{
Expand All @@ -25,6 +26,7 @@ class CollegeUser
virtual void assignID() = 0;

//GETS
unsigned long long int getID() const { return ID; }
string getName() const { return name; }
Date getDateOfRegistration() const { return dateOfRegistration; }
Date getDateOfBirth() const { return dateOfBirth; }
Expand Down
66 changes: 65 additions & 1 deletion Course.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#pragma once

#include "Course.h"
#include "Student.h"
#include "CourseUnit.h"
#include "Utilities.h"
#include "College.h"

Course::Course(string n, string a, College* c) : name(n), acronym(a), college(c) {
c->addCourse(this);
}

void Course::addCourseUnit(CourseUnit* cu)
{
Expand Down Expand Up @@ -60,4 +68,60 @@ bool Course::removeProfessor(Tutor* p)
}
}
return false;
}
}

vector<CourseUnit*> Course::getCourseUnits(unsigned short int y)
{
vector<CourseUnit*> courseUnits;

if (y >= 1 && y <= 5)
{
//GATHER ALL THE COURSE UNITS FROM THE YEAR
vector<CourseUnit*>::const_iterator cuIt;
for (cuIt = courseUnits.begin();
cuIt != courseUnits.end();
cuIt++)
{
if ((*cuIt)->getYear() == y) //SAME YEAR AS ARGUMENT
{
courseUnits.push_back(*cuIt);
}
}
}

return courseUnits;
}

vector<CourseUnit*> Course::getCourseUnitsNotCompleted(Student* s, unsigned short int y)
{
vector<CourseUnit*> courseUnitsFromYear, notCompleted;

if (y >= 1 && y <= 5)
{
//GATHER ALL THE COURSE UNITS FROM THE YEAR
courseUnitsFromYear = getCourseUnits(y);

//CHECK WHAT COURSE UNITS HAVE NOT BEEN COMPLETED
vector<CourseUnit*>::const_iterator cuIt;
for (cuIt = courseUnitsFromYear.begin();
cuIt != courseUnitsFromYear.end();
cuIt++)
{
if (//CHECK IF ALREADY ATENDING THE COURSE UNIT OR IF THE STUDENT HAS ALREADY COMPLETED THE COURSE UNIT
s->getClassesCurrentlyAtending().find((*cuIt)) == s->getClassesCurrentlyAtending().end()
&& s->getCompletedCourseUnits().find((*cuIt)) == s->getCompletedCourseUnits().end()
)
{
notCompleted.push_back(*cuIt); //IF NOT TO BOTH, ADD TO NOTCOMPLETED
}
}

}

return notCompleted;
}

bool compareCourseByName(Course* c1, Course* c2)
{
return (c1->getName() < c2->getName());
}
19 changes: 10 additions & 9 deletions Course.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
#ifndef COURSE_H
#define COURSE_H

//#include <vector>
//#include <string>

#include "College.h"
#include <vector>
#include <string>
using namespace std;

class College;
class Tutor;
class CourseUnit;
class Student;

//ADICIONAR MESTRADO/LICENCIATURAS/DOUTURAMENTOS COMO CLASSES DERIVADAS


class Course
{
private:
Expand All @@ -27,22 +23,27 @@ class Course

public:
//MEMBER FUNCTIONS
Course(string n, string a, College* c) : name(n), acronym(a), college(c) {}
Course(string n, string a, College* c);
void addCourseUnit(CourseUnit* cu);
bool removeCourseUnit(CourseUnit* cu);
void addStudent(Student* s);
bool removeStudent(Student* s);
void addProfessor(Tutor* p);
bool removeProfessor(Tutor* p);

//COMPARES
friend bool compareCourseByName(Course* c1, Course* c2);


//GETS
string getName() const { return name; }
string getAcronym() const { return acronym; }
vector<CourseUnit*> getCourseUnits() const { return courseUnits; }
vector<Student*> getStudents() const { return students; }
vector<Tutor*> getProfessors() const { return professors; }
College* getCollege() const { return college; }

vector<CourseUnit*> getCourseUnits(unsigned short int y);
vector<CourseUnit*> getCourseUnitsNotCompleted(Student* s, unsigned short int y);
};

#endif
70 changes: 69 additions & 1 deletion CourseUnit.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
#pragma once

#include <iostream>
#include "CourseUnit.h"
#include "Course.h"
#include "College.h"
#include "University.h"

void CourseUnit::addStudent(Student* s)
CourseUnit::CourseUnit(string n, string a, Course* c, unsigned short int y, unsigned short int s, unsigned int credits)
: name(n), acronym(a), year(y), semester(s), credits(credits), course(c)
{
c->addCourseUnit(this);
}

OptionalCourseUnit::OptionalCourseUnit(unsigned int mnos, string n, string a, Course* c, unsigned short int y, unsigned short int s, string sa, unsigned int cred)
: CourseUnit(n,a,c,y,s,cred), MAXIMUM_NUMBER_OF_STUDENTS(mnos), scientificArea(sa)
{

}

MandatoryCourseUnit::MandatoryCourseUnit(unsigned int mnospc, string n, string a, Course* c, unsigned short int y, unsigned short int s, unsigned int cred)
: CourseUnit(n, a, c, y, s, cred), MAXIMUM_NUMBER_OF_STUDENTS_PER_CLASS(mnospc)
{

}

bool OptionalCourseUnit::addStudent(Student* s)
{
if (getNumberOfStudents() >= MAXIMUM_NUMBER_OF_STUDENTS) {
return false;
}
studentsCurrentlyInCourseUnit.push_back(s);
return true;
}

bool MandatoryCourseUnit::addStudent(Student* s)
{
studentsCurrentlyInCourseUnit.push_back(s);
return true;
}

bool CourseUnit::removeStudent(Student* s)
Expand Down Expand Up @@ -60,4 +92,40 @@ bool CourseUnit::removeCourseUnitClass(CourseUnitClass* cuc)
}
}
return false;
}

void OptionalCourseUnit::show() const
{
cout << name << '\t'
<< acronym << '\t'
<< "Optional" << '\t'
<< scientificArea << '\t'
<< this->getNumberOfStudents() << '/' << MAXIMUM_NUMBER_OF_STUDENTS << '\n';

}

void MandatoryCourseUnit::show() const
{
cout << name << '\t'
<< acronym << '\t'
<< "Mandatory" << '\n';
}

bool compareCourseUnitByNumberStudents(CourseUnit* cu1, CourseUnit* cu2)
{
return (cu1->getNumberOfStudents() < cu2->getNumberOfStudents());
}

bool compareCourseUnitByName(CourseUnit* cu1, CourseUnit* cu2)
{
return (cu1->name < cu2->name);
}

bool compareCourseUnitByTime(CourseUnit* cu1, CourseUnit* cu2)
{
if (cu1->year < cu2->year)
return true;
else if (cu1->year > cu2->year)
return false;
else return (cu1->semester < cu2->semester);
}
Loading

0 comments on commit 22b52a8

Please sign in to comment.