HAI 1.3
O HAI IM pile
I HAS A length ITZ 0
I HAS A max ITZ -1
HOW IZ I pushin YR item
DIFFRINT ME'Z max AN BIGGR OF ME'Z max AN ME'Z length, O RLY?
YA RLY, ME HAS A SRS ME'Z length ITZ item, ME'Z max R SUM OF ME'Z max AN 1
NO WAI, ME'Z SRS ME'Z length R item
OIC
ME'Z length R SUM OF ME'Z length AN 1
IF U SAY SO
HOW IZ I popin
DIFFRINT ME'Z length AN 0, O RLY?
YA RLY
ME'Z length R DIFF OF ME'Z length AN 1
I HAS A item ITZ ME'Z SRS ME'Z length
ME'Z SRS ME'Z length R NOOB
FOUND YR item
OIC
IF U SAY SO
HOW IZ I gettinLen
FOUND YR ME'Z length
IF U SAY SO
KTHX
I HAS A stack ITZ LIEK A pile
stack IZ pushin YR "testvalue" MKAY
stack IZ pushin YR "value2" MKAY
VISIBLE stack IZ popin MKAY
stack IZ pushin YR "lolcat" MKAY
stack IZ pushin YR "longcat" MKAY
VISIBLE stack IZ popin MKAY
VISIBLE stack IZ popin MKAY
VISIBLE stack IZ popin MKAY
KTHXBYE
BEGIN program VERSION 1.3
CLASS stack{
ATTR VAR length = 0
ATTR VAR max = -1
FUNCTION push item{
IF THIS.max != (bigger(THIS.max, THIS.length){
THIS[THIS.length] = item
THIS.max+1
} ELSE {
THIS[THIS.length] = item
}
THIS.length+=1
}
FUNCTION pop{
IF THIS.length != 0{
length-=1
item = THIS[THIS.length]
THIS[THIS.length] = null
RETURN item
}
}
FUNCTION getLen{
RETURN THIS.length
}
}
stack s = new stack
s.push("testvalue")
s.push("value2")
PRINT stack.pop()
s.push("normal human being")
s.push("Basketball player")
PRINT s.pop()
PRINT s.pop()
PRINT s.pop()
END program