-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSc2720_Test.java
More file actions
42 lines (30 loc) · 840 Bytes
/
CSc2720_Test.java
File metadata and controls
42 lines (30 loc) · 840 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
/*
* Program Name: Lab 7 / Test
* Name: Stephanie L. Wyckoff
* Date: 2/24/2017
* Course: Data Structures Lab
* Professor: Duan
* TA: Pelin Icer, Shubin Wu
*
* Description: Program creates Character[] array, and new Stack. Checks if stack is empty, pushes each element to Stack, pops off last element, checks if Stack is empty and prints stack after each call.
*
* Input: none.
*
* Output: Stack.
*/
public class Test {
public static void main(String[] args) {
Character[] arr = {'H','E','Y','Y','E','Y','A','A','E','Y'};
Stack s = new Stack(arr.length);
System.out.println(s.isEmpty() + "\n");
for(int i = 0; i < arr.length; i++) {
s.push(arr[i]);
s.printStack();
}
s.pop();
s.printStack();
s.peek();
s.printStack();
System.out.println(s.isEmpty() + "\n");
}
}