//Megat Irfan Zackry Bin Ismail
//A20EC0205

#include <iostream>
using namespace std;

struct stud{
	string name;
	int age;
	char gender;
	stud *next;
};

//const int size=5;

class StackADT{
	private:
		stud *top;
	public:
		StackADT();
		bool isEmpty();
		bool isFull();
		void push(string n, int a, char g);
		void pop();
		stud *stackTop();		
};

StackADT::StackADT(){
	top = NULL;
}

bool StackADT::isFull(){
	return top == NULL;
}

bool StackADT::	isEmpty(){
	return top== NULL;
}

stud* StackADT::stackTop(){
	return top;
}

void StackADT::pop(){
	if (isEmpty()){
		cout << "\nUnable to pop, Stack is empty";
	}
	else {
		stud *temp = top;
		top = top->next;
		delete (temp);
	}
}

void StackADT::push (string n, int a, char g){
	if (isFull()){
		cout << "\nUnable to push, Stack is full";
	}
	else {
		stud *ns = new stud;
		ns->name = n;
		ns->gender = g; 
		ns->age = a;
		
		if (isEmpty()){
			top = ns;
		}
		else {
			ns->next = top;
			top = ns;
		}
	}
}




int main(int argc, char** argv) {
	cout << "In main()";
	
	StackADT *sadt = new StackADT;
	cout << "\nIsEmpty???? : " << sadt->isEmpty();
	cout << "\nIsFull???? : " << sadt->isFull();
	sadt->pop();
	sadt->push("1Mia", 44, 'f');
	sadt->push("2Mia", 44, 'f');
	sadt->push("3Mia", 44, 'f');
	sadt->push("4Mia", 44, 'f');
	sadt->push("5Mia", 44, 'f');
	sadt->push("6Mia", 44, 'f');
	cout << "\nIsEmpty???? : " << sadt->isEmpty();
	cout << "\nIsFull???? : " << sadt->isFull();
	
	stud *attop = sadt->stackTop();
	cout << "\nAt top \nstud name : "<< attop->name << "\ngender : " <<attop->gender << "\nage : "<<attop->age;
	
	sadt->pop();
	attop = sadt->stackTop();
	cout << "\nAt top \nstud name : "<< attop->name << "\ngender : " <<attop->gender << "\nage : "<<attop->age;
	return 0;
}
