1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
#ifndef Student_type
#define Student_type
#include <cstring>
#include <sstream>
#include <iostream>
#include <iomanip>
#include "List.h"
#include "Book.h"
using namespace std;
//student info
class Student {
public:
char name[30];
char id[10];
char course[3];
char phone_no[10];
stringstream NAME, ID, COURSE, PHONE;
string SName, SID, SCourse, SPhone;
Student();
friend ostream& operator<< (ostream&, Student);
};
Student::Student()
{
NAME << name;
NAME >> SName;
cout << "Please enter the student name :" << endl;
cin >> name;
ID << id;
ID >> SID;
cout << endl << "Please enter theid student id :" << endl;
cin >> id;
bool setID(const int Sid) // returns true if successful
{
if (Sid < 1) // ID must be > 0
return false;
id = Sid;
return true;
}
COURSE << course;
COURSE >> SCourse;
retry:
cout << endl << "Please enter the student course :" << endl;
cin >> course;
cin.ignore(256, '\n');
if (course == 'CS')
{
}
else if (course == 'IA')
{
}
else if (course == 'CT')
{
}
else if (course == 'CN')
{
}
else if (course == 'IB')
{
}
else
{
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "please enter only CS, CT, IA, IB and CN only.";
cout << endl << "Please enter the student course :" << endl;
cin >> course;
goto retry;
}
PHONE << phone_no;
PHONE >> SPhone;
cout << endl << "Please enter the student phone number :" << endl;
cin >> phone_no;
cout << endl;
while (ispunct(phone_no))
{
cout << "ERROR: Invalid input!" << endl;
cin.clear();
cin.ignore(100, '\n');
cin >> phone_no;
}
}
ostream& operator << (ostream& out, Student stu)
{
}
|