// A User interface contains two types of user input controls:
// •) TextInput - which accepts all characters
// •) NumericInput - which accepts only numeric characters (0-9).
// Implement TextInput and NumericInput with below requirements:
// TextInput:
// •) Public Method 'void Add(char c)' - adds the given character to the current value
// •) Public Method 'string GetValue()' - returns the current value
// NumericInput:
// •) Inherits TextInput
// •) Overrides the 'void Add(char c)' method so that each non-numeric character is ignored
using System;
/// <summary>
/// TextInput, which accepts all characters
/// </summary>
public class TextInput {
}
/// NumericInput, which accepts only digits.
public class NumericInput {
/// Test class
public class UserInput {
public static void Main(string[] args) {
TextInput textInput = new TextInput();
textInput.Add('1');
textInput.Add('a');
textInput.Add('0');
Console.WriteLine(textInput.GetValue()); // 1a0
TextInput numericInput = new NumericInput();
numericInput.Add('1');
numericInput.Add('a');
numericInput.Add('0');
Console.WriteLine(numericInput.GetValue()); //10