Created
May 21, 2020 16:33
-
-
Save FrostDelta123/b0d79eccd9fff583ea39141a3007b495 to your computer and use it in GitHub Desktop.
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
void FileUtil::enterStudent(){ | |
struct student stud; | |
string fa, name, ot, fio, date, kaf, group; | |
cout << "Введите Фамилию." << endl; | |
getline(cin, fa); | |
fio.append(fa); | |
cout << "Введите Имя." << endl; | |
getline(cin, name); | |
fio.append(" " + name); | |
cout << "Введите Отчество." << endl; | |
getline(cin, ot); | |
fio.append(" " + ot); | |
strcpy_s(stud.name, fio.c_str()); | |
cout << "Введите дату рождения в формате ДД.ММ.ГГГГ" << endl; | |
getline(cin, date); | |
while (!Date::isValid(date)){ | |
cout << "Дата введена некорректно! Повторите ввод." << endl; | |
getline(cin, date); | |
} | |
strcpy_s(stud.birth, date.c_str()); | |
cout << "Введите год постепления в университет." << endl; | |
string temp; | |
getline(cin, temp); | |
while(!Utils::isValid(temp)){ | |
cout << "Год введён некорректно! Повторите ввод." << endl; | |
getline(cin, temp); | |
} | |
stud.postup = stoi(temp); | |
cout << "Введите факультет, кафедру." << endl; | |
getline(cin, kaf); | |
strcpy_s(stud.kaf, kaf.c_str()); | |
//сделать возможность пробелов для группы | |
cout << "Введите группу." << endl; | |
getline(cin, group); | |
strcpy_s(stud.group, group.c_str()); | |
cout << "Введите номер зачётки." << endl; | |
string temp2; | |
getline(cin, temp2); | |
while(!Utils::isValid(temp2)){ | |
cout << "Номер введён некорректно! Повторите ввод." << endl; | |
getline(cin, temp2); | |
} | |
stud.zachetka = stoi(temp2); | |
int x; | |
string str; | |
cout << "Введите количество сессий" << endl; | |
getline(cin, str); | |
while(!Utils::isValid(str)){ | |
cout << "Введите число от 1 до 9."; | |
getline(cin, str); | |
} | |
while(stoi(str) <= 0 || stoi(str) > 9){ | |
cout << "Введите число от 1 до 9."; | |
getline(cin, str); | |
} | |
x = stoi(str); | |
//Ввести функцию-выход. | |
for(int y = 0; y < x; y++){ | |
//исправить номер сессии | |
cout << "Введите данные для сессии #" + to_string(y) << endl; | |
string subj, tem; | |
string count; | |
cout << "Введите количество предметов в данной сессии." << endl; | |
getline(cin, count); | |
while(!Utils::isValid(count)) { | |
cout << "Введите цифру от 1 до 10" << endl; | |
getline(cin, count); | |
} | |
while(stoi(count) < 1 || stoi(count) > 10){ | |
cout << "Введите цифру от 1 до 10" << endl; | |
getline(cin, count); | |
} | |
for(int num = 0; num < stoi(count); num++) { | |
struct Session session; | |
cout << "Введите предмет." << endl; | |
getline(cin, subj); | |
char ff[100]; | |
strcpy_s(ff, subj.c_str()); | |
strcpy_s(session.subj[num], ff); | |
cout << "Введите оценку по предмету " + subj << endl; | |
getline(cin, tem); | |
while (!Utils::isValid(tem)) { | |
cout << "Оценка введена неверно, повторите." << endl; | |
getline(cin, tem); | |
} | |
while (stoi(tem) < 2 || stoi(tem) > 5) { | |
cout << "Оценка введена неверно, повторите. Введите число от 2 до 5." << endl; | |
getline(cin, tem); | |
} | |
session.marks[num] = stoi(tem); | |
stud.sessions[x] = session; | |
} | |
} | |
cout << "top" << endl; | |
FILE* file; | |
file = fopen ("person.dat", "a"); | |
fwrite(&stud, sizeof(struct student),1, file); | |
fclose(file); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment