File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
src/main/java/com/galvanize Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Stage 1: Build .jar
2
+ FROM openjdk:13.0-jdk-slim as builder
3
+ VOLUME /tmp
4
+ COPY . .
5
+ RUN ./gradlew test --tests StackTestCase
Original file line number Diff line number Diff line change 1
1
package com .galvanize ;
2
+
3
+ import java .util .ArrayList ;
4
+
5
+ public class Stack {
6
+ public boolean empty ;
7
+ private ArrayList items ;
8
+
9
+ public Stack () {
10
+ this .empty = true ;
11
+ this .items = new ArrayList ();
12
+ }
13
+
14
+ public int count () {
15
+ return this .items .size ();
16
+ }
17
+
18
+ public void push (Object item ) {
19
+ this .items .add (item );
20
+ this .empty = false ;
21
+ }
22
+
23
+ public Object pop () {
24
+ int lastIndex = this .count () -1 ;
25
+ Object lastItem = this .items .get (lastIndex );
26
+ this .items .remove (lastIndex );
27
+ return lastItem ;
28
+ }
29
+
30
+ public Object peek () {
31
+ int lastIndex = this .count () -1 ;
32
+ return this .items .get (lastIndex );
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments