Skip to content

Commit

Permalink
we got a tiny menu which is helpful for the rest of project. i also a…
Browse files Browse the repository at this point in the history
…dded the link to the schedule. now we need to make it clean and pretty such as the grade page
  • Loading branch information
liranbg committed Mar 27, 2014
1 parent 9347e8c commit 084358d
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
60 changes: 60 additions & 0 deletions jceDates.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include "jceDates.h"
#include <sstream> //to_string function

template <typename T>
std::string to_string(T value)
{
std::ostringstream os;
os << value;
return os.str();
}
jceDates::jceDates()
{
//defaul choises.
this->fSemester = "0";
this->fYear = "2010";
this->tSemester = "2";
this->tYear = "2014";
}
void jceDates::setDate()
{
int fy,fs,ty,ts;
while (true) {
system("clear");
std::cout << "\n----------------jce API alpha----------------" << std::endl;
std::cout << "\tplease specify the date" << std::endl;
std::cout << "\t\tFrom year: ";
std::cin >> fy;
std::cout << "\t\tFrom semester: ";
std::cin >> fs;
std::cout << "\t\tTo year: ";
std::cin >> ty;
std::cout << "\t\tTo semester: ";
std::cin >> ts;
if (!(checkSemesterInput(ts) && checkSemesterInput(fs)
&& checkYearInput(fy) && checkYearInput(ty)))
printf("your input is out of range.\n please try again.");
else
{
this->fSemester = to_string(fs);
this->fYear = to_string(fy);
this->tSemester = to_string(ts);
this->tYear = to_string(ty);
break;
}
}
}

bool jceDates::checkSemesterInput(int num)
{
if ((num > 3) || (num < 0)) //out of semester range
return false;
return true;
}
bool jceDates::checkYearInput(int num)
{
if ((num > 2020) || (num < 2000)) //out of year range
return false;
return true;

}
30 changes: 30 additions & 0 deletions jceDates.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef JCE_DATES_H
#define JCE_DATES_H

#include <iostream>

class jceDates
{
public:
jceDates();
~jceDates() {};
void setDate();
std::string getFYear() { return this->fYear;}
std::string getTYear() { return this->tYear;}
std::string getFSemester() { return this->fSemester;}
std::string getTSemester() { return this->tSemester;}

private:
std::string fYear; //from
std::string fSemester;

std::string tYear; //to
std::string tSemester;

bool checkSemesterInput(int);
bool checkYearInput(int);


};

#endif

0 comments on commit 084358d

Please sign in to comment.