Answer:
Explanation:
public class Main
{
private static String val; //current val
public static class TextInput
{
public TextInput()
{
val= new String();
}
public void add(char c)
{
if(val.length()==0)
{
val=Character.toString(c);
}
else
{
val=val+c;
}
}
public String getvalue()
{
return val;
}
}
public static class NumericInput extends TextInput
{
Override
public void add(char c)
{
if(Character.isDigit(c))
{
//if character is numeric
if(val.length()==0)
{
val=Character.toString(c);
}
else
{
val=val+c;
}
}
}
}
public static void main(String[] args)
{
TextInput input = new NumericInput();
input.add('1');
input.add('a');
input.add('0');
System.out.println(input.getvalue());
}
}