Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Stack {
- List items;
- Stack(this.items);
- @override
- String toString() => 'List :$items';
- void push(int item) {
- this.items.add(item);
- }
- int pull() {
- return this.items.removeLast();
- }
- bool is_empty() {
- if (this.items == []) {
- return true;
- } else {
- return false;
- }
- }
- }
- main() {
- var s = Stack([10, 9]);
- s.push(1);
- s.push(2);
- s.push(3);
- print(s);
- print("---------");
- while (!s.is_empty()) {
- int item = s.pull();
- print(item);
- }
- }
Add Comment
Please, Sign In to add comment