CJCoding With Joseph

Encapsulated Stack

Build a class NumberStack that hides a private List<int>. Provide:
- Push(int n) adds n to the top
- Pop() removes and returns the top (most recently pushed) item
- a read-only Count property with the number of items left

Do not write a Main method.

After Push(1), Push(2), Push(3), the program prints Pop() on one line then Count on the next:
3
2

Expected Output:

3
2
Topics:
Encapsulation
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.