forked from aneez9n/Basic-Projects
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack_Class.java
More file actions
Latest commit
58 lines (54 loc) · 1022 Bytes
/
Copy pathStack_Class.java
File metadata and controls
58 lines (54 loc) · 1022 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
packagescope_operator_validation;
publicclassStack_Class
{
intsize;
charList[];
inttop;
publicStack_Class(ints)
{
this.size = s;
this. List = newchar[size];
this.top = -1;
}
// underflow
publicbooleanis_empty()
{
returntop == -1;
}
//oveflow
publicbooleanis_full()
{
returntop == List.length - 1;
}
//insertion
publicvoidpush(charnum)
{
if(is_full())
{
// System.out.println(" can not add, already full");
}
else
{
top++;
List[top] = num;
}
}
//deletion
publiccharpop()
{
charentry = 'm';
if(is_empty())
{
//System.out.println("Stack is empty. Can not remove element.");
}
else
{
entry = List[top--];
}
returnentry;
}
publiccharpeak()
{
returnList[top];
}
}