jce-manager/src/jceData/Calendar/calendarCourse.cpp

157 lines
3.5 KiB
C++
Raw Normal View History

#include "calendarCourse.h"
calendarCourse::calendarCourse(int serial, std::string name, std::string type, std::string lecturer, double points,
double semesterHours, std::string dayAndHour,
std::string room) : Course(serial,name, type,points)
{
this->lecturer = lecturer;
this->semesterHours = semesterHours;
this->room = room;
setDayAndHour(dayAndHour);
}
void calendarCourse::setDayAndHour(std::string phrase)
{
int ctr = 0;
std::string temp = "";
QTime timetemp;
char *tok;
char* textToTok = strdup(phrase.c_str());
tok = strtok(textToTok, " -");
while(tok != NULL)
{
temp = tok;
switch (ctr)
{
case 0:
setDay(temp);
break;
case 1:
timetemp = QTime::fromString(QString::fromStdString(temp),"hh:mm");
setHourBegin(timetemp.hour());
setMinutesBegin(timetemp.minute());
break;
case 2:
timetemp = QTime::fromString(QString::fromStdString(temp),"hh:mm");
setHourEnd(timetemp.hour());
setMinutesEnd(timetemp.minute());
break;
}
ctr++;
tok = strtok(NULL, " -");
}
}
std::string calendarCourse::getLecturer() const
{
return lecturer;
}
void calendarCourse::setLecturer(const std::string &value)
{
lecturer = value;
}
double calendarCourse::getSemesterHours() const
{
return semesterHours;
}
void calendarCourse::setSemesterHours(double value)
{
semesterHours = value;
}
int calendarCourse::getHourBegin() const
{
return hourBegin;
}
void calendarCourse::setHourBegin(int value)
{
hourBegin = value;
}
int calendarCourse::getMinutesBegin() const
{
return minutesBegin;
}
void calendarCourse::setMinutesBegin(int value)
{
minutesBegin = value;
}
int calendarCourse::getHourEnd() const
{
return hourEnd;
}
void calendarCourse::setHourEnd(int value)
{
hourEnd = value;
}
int calendarCourse::getMinutesEnd() const
{
return minutesEnd;
}
void calendarCourse::setMinutesEnd(int value)
{
minutesEnd = value;
}
std::string calendarCourse::courseToString()
{
std::string courseText = "";
courseText += " " + std::to_string(this->getSerialNum());
courseText += " " + this->getName();
courseText += " " + this->getType();
courseText += " " + this->lecturer;
courseText += " " + std::to_string(this->getPoints());
courseText += " " + std::to_string(this->semesterHours);
courseText += " " + this->day;
courseText += " " + std::to_string(this->hourBegin) + ":" + std::to_string(this->minutesBegin) + "-" + std::to_string(this->hourEnd) + ":" + std::to_string(this->minutesEnd);
courseText += " " + this->room;
courseText += "\n";
return courseText;
}
2014-09-01 22:19:24 +00:00
int calendarCourse::getDay() const
{
return day;
}
void calendarCourse::setDay(const std::string &value)
{
2014-09-01 22:19:24 +00:00
std::string dayTemp = value.substr(0,2);
if (dayTemp.compare("\u05D0") == 0) //alef
day = 1;
else if (dayTemp.compare("\u05D1") == 0) //bet
day = 2;
else if (dayTemp.compare("\u05D2") == 0) //gimel
day = 3;
else if (dayTemp.compare("\u05D3") == 0) //dalet
day = 4;
else if (dayTemp.compare("\u05D4") == 0) //hey
day = 5;
else if (dayTemp.compare("\u05D5") == 0) //vav
day = 6;
else
day= -1;
}
std::string calendarCourse::getRoom() const
{
return room;
}
void calendarCourse::setRoom(const std::string &value)
{
room = value;
}