-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
we got a tiny menu which is helpful for the rest of project. i also a…
…dded the link to the schedule. now we need to make it clean and pretty such as the grade page
- Loading branch information
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |