/UserInputKata

Did a simple beginner test thing

Primary LanguageC#

https://www.testdome.com/questions/c-sharp/user-input/

User interface contains two types of user input controls: TextInput, which accepts all characters and NumericInput, which accepts only digits.

Implement the class TextInput that contains:

  • Public method void Add(char c) - adds the given character to the current value X
  • Public method string GetValue() - returns the current X

Implement the class NumericInput that:

  • Inherits TextInput
  • Overrides the Add method so that each non-numeric character is ignored X
  • For example, the following code should output "10": TextInput input = new NumericInput(); input.Add('1'); input.Add('a'); input.Add('0'); Console.WriteLine(input.GetValue());