In this program how can i overload the pop() method to use two pop() methods (int and float) in a program as i used two push() methods ?
class Stack{
int StackArrayI[] = new int[3];
float StackArrayF[] = new float[3];
int tos=-1;
public void push(int value){
if (tos==2)
System.out.print ("Stack already Full..!\n");
else
StackArrayI[++tos] = value;
}
public void push(float fvalue){
if (tos==2)
System.out.print ("Stack already Full..!\n");
else
StackArrayF[++tos] = fvalue;
}
float pop(){
if (tos==-1){
System.out.print ("Stack is Empty");
return 0;
}
else
return StackArrayF[tos--];
}
}
I want to create another pop() method of type integer but i have to pass the parameter to create another pop() method !! what paramter should i pass since there is no need to pass the parameter in pop() method ?
our teacher advised us to overload both pop() and push()..!