โ Back to Encapsulation
Question 475
Encapsulated Stack
Encapsulated Stack
Build a classNumberStackthat hides aprivate List<int>. Provide: -Push(int n)addsnto the top -Pop()removes and returns the top (most recently pushed) item - a read-onlyCountproperty with the number of items left Do not write aMainmethod. AfterPush(1),Push(2),Push(3), the program printsPop()on one line thenCounton 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.