forked from Ameesha15/DSA-ALGORITHMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPersonStack.java
More file actions
37 lines (34 loc) · 730 Bytes
/
Copy pathPersonStack.java
File metadata and controls
37 lines (34 loc) · 730 Bytes
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
public class PersonStack {
private Person [] stack;
private int top;
private int size;
public PersonStack(){
top = -1;
size = 50;
stack = new Person[50];
}
public PersonStack(int size){
top = -1;
this.size = size;
stack = new Person[this.size];
}
public boolean push(Person value){
if(!isFull()){
top++;
stack[top]=value;
return true;
}
else{
return false;
}
}
public Person pop(){
return stack[top--];
}
public boolean isEmpty(){
return (top == -1);
}
public boolean isFull(){
return(top==stack.length - 1);
}
}