I am trying to create a student management systems using classes and I am a beginner in OOP because my school does not include OOP in my IT course.
I am trying to view All Subjects in the TEACHER MAIN MENU and the problem is the result is always Empty Subject List.
Below is my code in DEVC++ (Embarcadero 6.3)
#include <iostream>
#include <conio.h> // using of getch() - counterpart function of system("pause"); and password security
#include <string>
#include <cstdlib> // rand() function
#include <iomanip>
#include <Windows.h> // for gotoxy function
#include <limits> // inside cin.ignore function() >> numeric_limits<streamsize>::max()
#include <cmath>
#include <time.h> // seeding for random ID number generator and password generator
#define SIZE_adm 3
using namespace std;
void gotoxy(int x, int y){
HANDLE hConsoleOutput;
COORD dwCursorPosition;
cout.flush();
dwCursorPosition.X = x;
dwCursorPosition.Y = y;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput,dwCursorPosition);
}
int main();
void mainDesign(){
gotoxy(25,3);
for(int a=0; a<55; a++){
cout << char(219);
}
gotoxy(25,25);
for(int a=0; a<55; a++){
cout << char(219);
}
}
struct Admin{
string adm_id;
string adm_name;
string adm_pW;
}admin[SIZE_adm];
class Student{
public:
int std_id;
string std_name;
string std_email;
string std_pW;
Student* nextStd;
Student(){ //public constructor
std_id=0;
std_name="\0";
std_email="\0";
std_pW="\0";
nextStd=NULL;
}
Student(int id, string name, string email, string pW){
std_id = id;
std_name = name;
std_email = email;
std_pW = pW;
}
};
class StdList{
public:
Student* firstStd=NULL;
StdList(){
firstStd;
}
StdList(Student *std){
firstStd = std; //address of 1st node
}
public:
Student* stdDataExist(int std_id){
Student* tempStd = NULL;
Student* ptrStd = firstStd;
while(ptrStd!=NULL){
if(ptrStd->std_id == std_id){
tempStd = ptrStd;
}
ptrStd=ptrStd->nextStd;
}
return tempStd;
}
public:
//Add Student Data
void AddStdData(Student *std){
if(stdDataExist(std->std_id)!=NULL){
cout << "Student Data already EXISTS!" << endl;
}
else{
if(firstStd == NULL){ // no std data on list
firstStd = std;
gotoxy(31,11); cout << "Student Data Added!" << endl;
}
else{ //if list has already have std data
Student* ptrStd = firstStd;
while(ptrStd->nextStd != NULL){
ptrStd = ptrStd->nextStd;
}
ptrStd->nextStd = std;
gotoxy(31,11); cout << "Student Data Added!" << endl;
}
}
}
public:
//Delete Student Data
void delStdData(int std_id){
if(firstStd == NULL){
gotoxy(31,11); cout << "Student Data is EMPTY. Cannot delete a student data." << endl;
}
else if(firstStd != NULL){
gotoxy(31,6); cout << "Enter Student ID: "; cin >> std_id;
if(firstStd->std_id == std_id){
firstStd = firstStd->nextStd;
gotoxy(31,11); cout << "Student Data Deleted!" << endl;
}
else{
Student* tempStd = NULL;
Student* prevStd = firstStd;
Student* currStd = firstStd->nextStd;
while(currStd!=NULL){
if(currStd->std_id == std_id){
tempStd = currStd;
currStd = NULL;
}
else{
prevStd = prevStd->nextStd;
currStd = currStd->nextStd;
}
}
if(tempStd != NULL){ //unlinking happens
prevStd->nextStd = tempStd->nextStd;
gotoxy(31,11); cout << "Student Data Deleted!" << endl;
}
else{
gotoxy(31,11); cout << "Student Data doesn't EXIST!" << endl;
}
}
}
}
public:
//Updating Student Data (not yet used)
void UpdateStdData(int std3_id, string std3_name, string std3_email, string std3_pW){
Student* ptrStd = stdDataExist(std3_id);
if(ptrStd!=NULL){
ptrStd->std_name = std3_name;
ptrStd->std_email = std3_email;
ptrStd->std_pW = std3_pW;
cout << "Student Data Updated Successfully!" << endl;
}
else{
cout << "Student Data doesn't EXIST!" << endl;
}
}
public:
//View Student List
void ViewStdList(){
if(firstStd == NULL){
gotoxy(31,11); cout << "Empty Student Data!" << endl;
}
else{
Student* tempStd = firstStd;
while(tempStd!=NULL){
cout << "\t\t\t\tStudent ID: " << setfill('0') << setw(5) << tempStd->std_id << endl;
cout << "\t\t\t\tStudent Name: " << tempStd->std_name << endl;
cout << "\t\t\t\tStudent Email: " << tempStd->std_email << endl;
cout << "\t\t\t\tStudent Password: " << tempStd->std_pW << endl << endl;
tempStd = tempStd->nextStd;
}
}
}
};
class Subject{
public:
int subj_id;
string subj_name;
Subject* nextSubj;
Subject(){
subj_id=0;
subj_name="\0";
nextSubj=NULL;
}
Subject(int subj2_id, string subj2_name){
subj_id = subj2_id;
subj_name = subj2_name;
}
};
class SubjList{
public:
Subject* fSubj=NULL;
SubjList(){
fSubj;
}
SubjList(Subject *sbj){
fSubj = sbj; //address of 1st node
}
public:
Subject* subjExist(int subj_id){
Subject* tempSubj = NULL;
Subject* ptrSubj = fSubj;
while(ptrSubj!=NULL){
if(ptrSubj->subj_id == subj_id){
tempSubj = ptrSubj;
}
ptrSubj=ptrSubj->nextSubj;
}
return tempSubj;
}
public:
//Add Subject
void AddSubject(Subject *sbj){
if(subjExist(sbj->subj_id)!=NULL){
gotoxy(31,11); cout << "This subject already EXISTS!" << endl;
}
else{
if(fSubj == NULL){ // no std data on list
fSubj = sbj;
gotoxy(31,11); cout << "Subject Added!" << endl;
}
else{ //if list has already have std data
Subject* ptrSubj = fSubj;
while(ptrSubj->nextSubj != NULL){
ptrSubj = ptrSubj->nextSubj;
}
ptrSubj->nextSubj = sbj;
gotoxy(31,11); cout << "Student Data Added!" << endl;
}
}
}
public:
//Delete Subject
void delSubj(int subj_id){
if(fSubj == NULL){
gotoxy(31,11); cout << "Subject List is EMPTY. Cannot delete a subject." << endl;
}
else if(fSubj!=NULL){
gotoxy(31,6); cout << "Enter Student ID: "; cin >> subj_id;
if(fSubj->subj_id == subj_id){
fSubj = fSubj->nextSubj;
gotoxy(31,11); cout << "Subject Deleted!" << endl;
}
else{
Subject* tempSubj = NULL;
Subject* prevSubj = fSubj;
Subject* currSubj = fSubj->nextSubj;
while(currSubj!=NULL){
if(currSubj->subj_id == subj_id){
tempSubj = currSubj;
currSubj = NULL;
}
else{
prevSubj = prevSubj->nextSubj;
currSubj = currSubj->nextSubj;
}
}
if(tempSubj != NULL){ //unlinking happens
prevSubj->nextSubj = tempSubj->nextSubj;
gotoxy(31,11); cout << "Subject Deleted!" << endl;
}
else{
gotoxy(31,11); cout << "Subject doesn't EXIST!" << endl;
}
}
}
}
public:
//Updating a Subject
void UpdateSubj(int subj3_id, string subj3_name){
Subject* ptrSubj = subjExist(subj3_id);
if(ptrSubj!=NULL){
ptrSubj->subj_name = subj3_name;
gotoxy(31,11); cout << "Subject Updated Successfully!" << endl;
}
else{
gotoxy(31,11); cout << "Subject doesn't EXIST!" << endl;
}
}
public:
//View Subjects
void ViewSubj(){
if(fSubj == NULL){
gotoxy(31,11); cout << "Empty Subject List!" << endl;
}
else{
Subject* tempSubj = fSubj;
while(tempSubj!=NULL){
cout << "\t\t\t\tSubject ID: " << setfill('0') << setw(5) << tempSubj->subj_id << endl;
cout << "\t\t\t\tSubject Name: " << tempSubj->subj_name << endl << endl;
tempSubj = tempSubj->nextSubj;
}
}
}
};
class Teacher{
public:
int tchr_id;
string tchr_name;
string tchr_email;
string tchr_pos;
string tchr_Pw;
Teacher* nextTchr;
Teacher(){
tchr_id=0;
tchr_name="\0";
tchr_email="\0";
tchr_pos="\0";
tchr_Pw="\0";
nextTchr=NULL;
}
Teacher(int Tid, string Tname, string Temail, string Tpos, string TPw){
tchr_id=Tid;
tchr_name=Tname;
tchr_email=Temail;
tchr_pos=Tpos;
tchr_Pw=TPw;
}
};
class ListofTchrs{
public:
Teacher* fTchr=NULL;
ListofTchrs(){
fTchr;
}
ListofTchrs(Teacher* tch){
fTchr = tch; //address of 1st node
}
public:
Teacher* tchExist(int tchr_id){
Teacher* tempTch = NULL;
Teacher* ptrTch = fTchr;
while(ptrTch!=NULL){
if(ptrTch->tchr_id == tchr_id){
tempTch = ptrTch;
}
ptrTch=ptrTch->nextTchr;
}
return tempTch;
}
public:
//Check if teacher id and teacher password exist
Teacher* TchIdPw_exist(int tchid, string passW){
Teacher* tempTch = NULL;
Teacher* ptrTch = fTchr;
while(ptrTch!=NULL){
if((ptrTch->tchr_id == tchid) && (ptrTch->tchr_Pw == passW)){
tempTch = ptrTch;
}
ptrTch=ptrTch->nextTchr;
}
return tempTch;
}
public:
//Add Teacher Data
void AddTchData(Teacher *tch){
if(tchExist(tch->tchr_id)!=NULL){
gotoxy(31,16); cout << "Teacher Data already EXISTS!" << endl;
}
else{
if(fTchr == NULL){
fTchr = tch;
gotoxy(31,16); cout << "Teacher Data Added!" << endl;
}
else{
Teacher* ptrTch = fTchr;
while(ptrTch->nextTchr != NULL){
ptrTch = ptrTch->nextTchr;
}
ptrTch->nextTchr = tch;
gotoxy(31,16); cout << "Teacher Data Added!" << endl;
}
}
}
public:
//Delete Teacher Data
void DelTchrData(int tchr_id){
if(fTchr == NULL){
gotoxy(31,11); cout << "Teachers' Data is EMPTY. Cannot delete a data." << endl;
}
else if(fTchr != NULL){
gotoxy(31,6); cout << "Enter Teacher ID: "; cin >> tchr_id;
if(fTchr->tchr_id == tchr_id){
fTchr = fTchr->nextTchr;
gotoxy(31,11); cout << "Teacher Data Deleted!" << endl;
}
else{
Teacher* tempTch = NULL;
Teacher* prevTch = fTchr;
Teacher* currTch = fTchr->nextTchr;
while(currTch!=NULL){
if(currTch->tchr_id == tchr_id){
tempTch = currTch;
currTch = NULL;
}
else{
prevTch = prevTch->nextTchr;
currTch = currTch->nextTchr;
}
}
if(tempTch != NULL){ //unlinking happens
prevTch->nextTchr = tempTch->nextTchr;
gotoxy(31,11); cout << "Teacher Data Deleted!" << endl;
}
else{
gotoxy(31,11); cout << "Teacher Data doesn't EXIST!" << endl;
}
}
}
}
public:
//Updating Teacher Data (not yet used)
void UpdateTchData(int tch2_id, string tch2_name, string tch2_email, string tch2_Pw){
Teacher* ptrTch = tchExist(tch2_id);
if(ptrTch!=NULL){
ptrTch->tchr_name = tch2_name;
ptrTch->tchr_email = tch2_email;
ptrTch->tchr_Pw = tch2_Pw;
gotoxy(31,11); cout << "Teacher Data Updated Successfully!" << endl;
}
else{
gotoxy(31,11); cout << "Teacher Data doesn't EXIST!" << endl;
}
}
public:
//Search Teacher ID & Password, Leading to Teacher Main Menu
void searchTchrIDandPW(int tchrid, string passW){
Teacher* srchID = TchIdPw_exist(tchrid,passW);
if(srchID != NULL){
gotoxy(30,5); cout << "Welcome, " << srchID->tchr_name << endl;
TchrHome: system("cls"); mainDesign();
string chTchr, bchT;
gotoxy(30,5); cout << "Welcome, " << srchID->tchr_name << endl;
gotoxy(30,7); cout << "A. View Teacher Data";
gotoxy(30,8); cout << "B. Update Teacher Data";
gotoxy(30,9); cout << "C. View All Subjects";
gotoxy(30,10); cout << "D. View Students";
gotoxy(30,11); cout << "0 - Logout User";
gotoxy(30,12); cout << "Input choice: "; cin >> chTchr;
if((chTchr == "A") || (chTchr == "a")){
system("cls"); system("color C0");
gotoxy(30,6); cout << "- - - - - - - - View Teacher Data - - - - - - - - ";
gotoxy(30,7); cout << "Teacher ID: " << srchID->tchr_id << endl;
gotoxy(30,8); cout << "Teacher Name: " << srchID->tchr_name << endl;
gotoxy(30,9); cout << "Teacher Email: " << srchID->tchr_email << endl;
gotoxy(30,10); cout << "Position: " << srchID->tchr_pos << endl;
gotoxy(30,11); cout << "Password: " << srchID->tchr_Pw << endl;
p1: gotoxy(30,15); cout << "Back to Teacher Main Menu? Press 1 to Continue: "; cin >> bchT;
if(bchT == "1"){goto TchrHome;}
else{system("cls"); goto p1;}
}
else if((chTchr == "B") || (chTchr == "b")){
system("cls"); system("color C0");
string UpdTch_name, UpdTch_email, UpdTch_pw;
gotoxy(30,6); cout << "- - - - - - - - Update Teacher Data - - - - - - - - ";
gotoxy(31,7); cout << "Teacher ID: " << srchID->tchr_id;
gotoxy(31,8);cout << "Teacher Name: "; cin >> UpdTch_name;
UpdTch_email = UpdTch_name + "@school.com";
gotoxy(31,9);cout << "Teacher Email: " << UpdTch_email;
gotoxy(31,10);cout << "Password: "; cin >> UpdTch_pw;
UpdateTchData(srchID->tchr_id, UpdTch_name, UpdTch_email, UpdTch_pw);
tc: gotoxy(30,15); cout << "Back to Teacher Main Menu? Press 1 to Continue: "; cin >> bchT;
if(bchT == "1"){goto TchrHome;}
else{system("cls"); goto tc;}
}
else if((chTchr == "C") || (chTchr == "c")){
system("cls"); system("color C0");
gotoxy(30,6); cout << "- - - - - - - - View All Subjects - - - - - - - - ";
cu: gotoxy(30,15); cout << "Back to Teacher Main Menu? Press 1 to Continue: "; cin >> bchT;
if(bchT == "1"){goto TchrHome;}
else{system("cls"); goto cu;}
}
else if(chTchr == "0"){system("cls"); main();}
else{
gotoxy(30,15); cout << "Wrong input. Please try again.\n"; goto TchrHome;
}
}
else{
gotoxy(30,13); cout << "Teacher ID / Password does NOT EXIST!\n";
}
}
public:
//View Teacher Data
void ViewTchData(){
if(fTchr == NULL){
gotoxy(31,11); cout << "Empty Teacher Data!" << endl;
}
else{
Teacher* tempTch = fTchr;
while(tempTch!=NULL){
cout << "\t\t\t\tTeacher ID: " << setfill('0') << setw(5) << tempTch->tchr_id << endl;
cout << "\t\t\t\tTeacher Name: " << tempTch->tchr_name << endl;
cout << "\t\t\t\tTeacher Email: " << tempTch->tchr_email << endl;
cout << "\t\t\t\tPosition: " << tempTch->tchr_pos << endl;
cout << "\t\t\t\tTeacher Password: " << tempTch->tchr_Pw << endl << endl;
tempTch = tempTch->nextTchr;
}
}
}
};
void ViewAdminUsers(struct Admin admin[SIZE_adm]){
gotoxy(30,5); cout << "= = = = = View Admin Users = = = = = \n ";
gotoxy(30,6); cout << "Admin ID\t" << "Admin Name\t" << "Admin Password\t" << endl;
for(int d=0; d<SIZE_adm; d++){
cout << "\t\t\t " << admin[d].adm_id << "\t" << admin[d].adm_name << "\t\t" << admin[d].adm_pW << "\n";
}
}
void AdminMainMenu(){
gotoxy(30,9); cout << "1) View Admin Users";
gotoxy(30,10); cout << "2) View Teacher Data";
gotoxy(30,11); cout << "3) Add Teacher Data";
gotoxy(30,12); cout << "4) Remove Teacher Data";
gotoxy(30,13); cout << "5) View Subjects";
gotoxy(30,14); cout << "6) Add New Subject";
gotoxy(30,15); cout << "7) Update Subject";
gotoxy(30,16); cout << "8) Remove Subject";
gotoxy(30,17); cout << "9) View Student Data";
gotoxy(30,18); cout << "10) Add Student Data";
gotoxy(30,19); cout << "11) Remove Student Data";
gotoxy(30,20); cout << "12) Logout Admin User";
gotoxy(30,22); cout << "Input choice: ";
}
int main(void){
Student std;
StdList std_list; //Singly Linked list with classes
Subject sbj;
SubjList sbj_List; //Singly Linked list with classes
Teacher tch;
ListofTchrs tch_List; //Singly Linked list with classes
srand(time(0)); //seeding of randomness
int std_id, sbj_id, tch_id;
string mainCH, std_name, std_email, std_passW, sbj_name;
string tch_name, tch_email, tchPos, tchPw;
Admin admin[SIZE_adm] = {
{"1001", "admin1", "sCH01_adm"},
{"1002", "admin2", "sCH02_adm"},
{"1003", "admin3", "sCH03_adm"},
};
home: mainDesign(); system("color 07");
gotoxy(30,7); cout << "Student Record Management Systems";
gotoxy(30,9); cout << "LOGIN AS:";
gotoxy(30,11); cout << "1. STUDENT";
gotoxy(30,12); cout << "2. TEACHER";
gotoxy(30,13); cout << "3. ADMIN";
gotoxy(30,14); cout << "4. Exit Program";
gotoxy(30,16); cout << "Input choice: "; cin >> mainCH;
if(mainCH == "1"){ //Student Main
string std_ch;
std2_home: system("cls"); mainDesign();
gotoxy(30,7); cout << "LOGIN AS STUDENT";
gotoxy(30,9); cout << "Student ID: ";
gotoxy(30,10); cout << "Password: ";
gotoxy(30,11); cout << "Return to Main Menu? 1)Yes or 2)No: "; cin >> std_ch;
if(std_ch == "1"){system("cls"); goto home;}
else if(std_ch == "2"){exit(0);}
else{
goto std2_home;
}
}
else if(mainCH == "2"){ // Teacher Main
string tchr_ch, inputTchPw; char pWTch; int inputTchID;
tchr2_home: system("cls"); system("color C0"); mainDesign();
gotoxy(30,7); cout << "LOGIN AS TEACHER";
gotoxy(30,9); cout << "Teacher ID: "; cin >> inputTchID;
gotoxy(30,10); cout << "Password: "; cin >> inputTchPw;
tch_List.searchTchrIDandPW(inputTchID,inputTchPw);
/*gotoxy(30,11); cout << "Return to Main Menu? Press 1 to Continue: "; cin >> tchr_ch;
if(tchr_ch == "1"){system("cls"); goto home;}
else{
goto tchr2_home;
}*/
}
else if(mainCH == "3"){ // Admin Main
string inputAdminPW, inputAdminID, chAdmin, chAd_mainMenu, returnADMM; char pWaD;
adm2_home: system("cls"); system("color 80"); mainDesign();
gotoxy(30,7); cout << "a) Admin Login Page";
gotoxy(30,8); cout << "b) Return to Main Menu";
gotoxy(30,9); cout << "Input choice: "; cin >> chAdmin;
if(chAdmin == "A" || chAdmin == "a"){ // go to admin login page
admin_loginP: system("cls"); mainDesign();
gotoxy(30,10); cout << "Admin Login Page\n\n";
gotoxy(30,12); cout << "Admin ID: "; cin >> inputAdminID;
gotoxy(30,13); cout << "Password: "; pWaD = _getch(); //cin >> inputAdminPW;
while((pWaD!=13)&&(pWaD!=8)){
inputAdminPW.push_back(pWaD);
cout << "*";
pWaD = _getch();
}
for(int a=0; a<SIZE_adm; a++){
if((inputAdminID == admin[a].adm_id) && (inputAdminPW == admin[a].adm_pW)){
ADMM: system("cls"); mainDesign(); gotoxy(30,7); cout <<"Welcome, "<< admin[a].adm_name << endl;
AdminMainMenu(); //Function for admin main menu
cin >> chAd_mainMenu;
Student* std = new Student();
Subject* sbj = new Subject();
Teacher* tch = new Teacher();
//View Admin Users
if(chAd_mainMenu == "1"){
viewAdU: system("cls"); mainDesign();
ViewAdminUsers(admin);
gotoxy(30,16); cout << "Return to Admin Main Menu? Y/N: ";
cin >> returnADMM;
if(returnADMM == "Y" || returnADMM == "y"){goto ADMM;}
else{goto viewAdU;}
break;
}
//View Teacher Data
if(chAd_mainMenu == "2"){
viewTch: system("cls");
gotoxy(30,5); cout << "- - - - - - List of Teachers - - - - - -\n";
tch_List.ViewTchData();
gotoxy(68,10); cout << "Return to Admin Main Menu? Y/N: ";
cin >> returnADMM;
if(returnADMM == "Y" || returnADMM == "y"){goto ADMM;}
else{goto viewTch;}
break;
}
//Add Teacher Data
if(chAd_mainMenu == "3"){
system("cls");
int tch_id=rand();
gotoxy(30,5); cout << "- - - - - - - Add Teacher Data - - - - - - -\n";
gotoxy(31,6); cout << "Teacher ID: " << setfill('0') << setw(5) << tch_id << endl;
gotoxy(31,7); cout << "Teacher Name: "; cin >> tch_name;
tch_email = tch_name + "@school.com";
gotoxy(31,8); cout << "Teacher Email: " << tch_email;
gotoxy(31,9); cout << "Password: "; cin >> tchPw;
gotoxy(31,10); cout << "Choose Position: ";
gotoxy(32,11); cout << "A: Instructor";
gotoxy(32,12); cout << "B: Associate Instructor";
gotoxy(32,13); cout << "C: Master Professor";
inPo: gotoxy(32,14); cout << "Input here: "; cin >> tchPos;
tch->tchr_id = tch_id;
tch->tchr_name = tch_name;
tch->tchr_email = tch_email;
tch->tchr_Pw = tchPw;
if(tchPos == "A" || tchPos == "a"){
tchPos = "Instructor";
tch->tchr_pos = tchPos;
}
else if(tchPos == "B" || tchPos == "b"){
tchPos = "AssociateInstructor";
tch->tchr_pos = tchPos;
}
else if(tchPos == "C" || tchPos == "c"){
tchPos = "MasterProfessor";
tch->tchr_pos = tchPos;
}
else{
gotoxy(31,16); cout << "Please try again!\n"; goto inPo; break;
}
tch_List.AddTchData(tch);
t01: gotoxy(68,10); cout << "Return to Admin Main Menu? Press Y to continue: "; cin >> returnADMM;
if(returnADMM == "Y" || returnADMM == "y"){goto ADMM;}
else{
gotoxy(68,11); cout << "Wrong input. Please try again.\n"; system("cls"); goto t01;
}
break;
}
//Remove Teacher Data
else if(chAd_mainMenu == "4"){
RemTch: system("cls");
gotoxy(30,5); cout << "- - - - - - Remove Teacher Data - - - - - -\n";
tch_List.DelTchrData(tch_id);
t02: gotoxy(68,10); cout << "Return to Admin Main Menu? Y/N: "; cin >> returnADMM;
if(returnADMM == "Y" || returnADMM == "y"){goto ADMM;}
else if(returnADMM == "N" || returnADMM == "n"){goto RemTch;}
else{
gotoxy(68,11); cout << "Wrong input. Please try again.\n"; system("cls"); goto t02;
}
}
// View Subjects
else if(chAd_mainMenu == "5"){
viewSubj: system("cls");
gotoxy(30,5); cout << "- - - - - - All Subject List - - - - - -\n";
sbj_List.ViewSubj();
gotoxy(68,10); cout << "Return to Admin Main Menu? Y/N: ";
cin >> returnADMM;
if(returnADMM == "Y" || returnADMM == "y"){goto ADMM;}
else{goto viewSubj;}
break;
}
//Add Subjects
else if(chAd_mainMenu == "6"){
AddSubj: system("cls");
int sbj_id=rand();
gotoxy(30,5); cout << "- - - - - - - Add Subjects - - - - - - -\n";
gotoxy(31,6); cout << "Subject ID: " << setfill('0') << setw(5) << sbj_id << endl;
gotoxy(31,7); cout << "Subject Name: "; cin >> sbj_name;
sbj->subj_id = sbj_id;
sbj->subj_name = sbj_name;
sbj_List.AddSubject(sbj);
ret3: gotoxy(68,10); cout << "Return to Admin Main Menu? Press Y to continue: "; cin >> returnADMM;
if(returnADMM == "Y" || returnADMM == "y"){goto ADMM;}
else{
gotoxy(68,11); cout << "Wrong input. Please try again.\n"; system("cls"); goto ret3;
}
break;
}
//Update Subject
else if(chAd_mainMenu == "7"){
UpdSubj: system("cls");
gotoxy(30,5); cout << "- - - - - - Update Subject Data - - - - - -\n";
gotoxy(31,6); cout << "Enter Subject ID: "; cin >> sbj_id;
gotoxy(31,7); cout << "Enter New Subject Name: "; cin >> sbj_name;
sbj_List.UpdateSubj(sbj_id, sbj_name);
r5: gotoxy(68,10); cout << "Return to Admin Main Menu? Y/N: "; cin >> returnADMM;
if(returnADMM == "Y" || returnADMM == "y"){goto ADMM;}
else if(returnADMM == "N" || returnADMM == "n"){goto UpdSubj;}
else{
gotoxy(68,11); cout << "Wrong input. Please try again.\n"; system("cls"); goto r5;
}
break;
}
//Remove Subject
else if(chAd_mainMenu == "8"){
RemSubj: system("cls");
gotoxy(30,5); cout << "- - - - - - Remove Subject Data - - - - - -\n";
sbj_List.delSubj(sbj_id);
r6: gotoxy(68,10); cout << "Return to Admin Main Menu? Y/N: "; cin >> returnADMM;
if(returnADMM == "Y" || returnADMM == "y"){goto ADMM;}
else if(returnADMM == "N" || returnADMM == "n"){goto RemSubj;}
else{
gotoxy(68,11); cout << "Wrong input. Please try again.\n"; system("cls"); goto r6;
}
}
//View Students
else if(chAd_mainMenu == "9"){
viewStd: system("cls");
gotoxy(30,5); cout << "- - - - - - Current Student Data - - - - - -\n";
std_list.ViewStdList();
gotoxy(68,10); cout << "Return to Admin Main Menu? Y/N: ";
cin >> returnADMM;
if(returnADMM == "Y" || returnADMM == "y"){goto ADMM;}
else{goto viewStd;}
break;
}
//Add Student Data
else if(chAd_mainMenu == "10"){
system("cls");
int std_id = rand();
gotoxy(30,5); cout << "- - - - - - Add Student Data - - - - - -\n";
gotoxy(31,6); cout << "Student ID: " << setfill('0') << setw(5) << std_id << endl;
gotoxy(31,7); cout << "Student Name: "; cin >> std_name;
std_email = std_name + "@school.com";
gotoxy(31,8); cout << "Student Email: " << std_email;
gotoxy(31,9); cout << "Student Password: "; cin >> std_passW;
std->std_id = std_id;
std->std_name = std_name;
std->std_email = std_email;
std->std_pW = std_passW;
std_list.AddStdData(std);
ret2: gotoxy(68,10); cout << "Return to Admin Main Menu? Press Y to continue: "; cin >> returnADMM;
if(returnADMM == "Y" || returnADMM == "y"){goto ADMM;}
else{
gotoxy(68,11); cout << "Wrong input. Please try again.\n"; system("cls"); goto ret2;
}
break;
}
//Remove Student Data
else if(chAd_mainMenu == "11"){
remStdData: system("cls");
gotoxy(30,5); cout << "- - - - - - Remove Student Data - - - - - -\n";
std_list.delStdData(std_id);
r4: gotoxy(68,10); cout << "Return to Admin Main Menu? Y/N: "; cin >> returnADMM;
if(returnADMM == "Y" || returnADMM == "y"){goto ADMM;}
else if(returnADMM == "N" || returnADMM == "n"){goto remStdData;}
else{
gotoxy(68,11); cout << "Wrong input. Please try again.\n"; system("cls"); goto r4;
}
}
//Logout Admin User
else if(chAd_mainMenu == "12"){goto adm2_home;}
else{
goto ADMM;
}
}
else{ // if incorrect UN or PW
if(a == SIZE_adm-1){
string menuInc;
mainDesign();
gotoxy(28,8); cout << "Incorrect Admin ID/Password.\n";
gotoxy(29,9); cout << "Go back to Main Menu? (Y/N): "; cin >> menuInc;
if(menuInc == "Y" || menuInc == "y"){
system("cls"); goto home;
}
else{
goto admin_loginP;
}
}
}
}
}
else if(chAdmin == "B" || chAdmin == "b"){ // return to main menu
system("cls"); goto home;
}
else{ // if wrong input, return to admin Home
goto adm2_home;
}
}
else if(mainCH == "4"){system("cls"); mainDesign(); gotoxy(30,8); cout << "Exiting the program.\n"; exit(0);}
else{ //if entered another number rather than 1-3 and it will also not accept special characters, letters, words
system("cls"); mainDesign();
gotoxy(30,18); cout << "Incorrect Input! Please try again.\n"; goto home;
}
return 0;
}