← Back to Encapsulation
Question 565
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 (see Expected Output).
Expected Output:
3 2
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Encapsulation
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.