CJCoding With Joseph
15free / daySign inCreate account

Roster Behind a Private List

The Team class hides a private List<string> of member names. Add a method Add(string name) that appends a name, a read-only property Count that returns how many members there are, and a method Roster() that returns the names joined by ", " (a comma followed by a space). The list itself is never exposed. The tester prints Count, then the roster. Do NOT write a Main method.

After adding "Ann" and "Bob" the program prints the output shown in Expected Output.

Expected Output:

2
Ann, Bob

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
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.