1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
givi [52]
2 years ago
11

The user interface contains two types of user input controls: TextInput, which accepts all characters and Numeric Input, which a

ccepts only digits.
1. Implement the class TextInput that contains:
O Public method def add(c : Char) - concatenates the given character to the current value
O Public method def getValue(): String - returns the current value
Implement the class NumericInput that:
O Inherits from TextInput
O Overrides the add method so that each non-numeric character is ignored
For example, the following code should output "10":
$input = new NumericInput();
$input->add('1');
$input->add('a');
$input->add('0');
echo $input->getValue();
The code skeleton is provided below:
<?php
class TextInput
{
}
class Numericinput
{
{
//$input = new NumericInput();
//$input->add('1');
//$input->add('a');
//$input->add('0');
//echo $input->getValue();
Computers and Technology
1 answer:
Shtirlitz [24]2 years ago
4 0

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());

}

}

You might be interested in
To ensure rapid recovery and security of data, backup data should be ________.
Nataly [62]

Answer:B kept at a secure location at the facility

Explanation:

8 0
3 years ago
2) The CPU is made from a silicon<br>b) Chip<br>C) pendrive<br>a) Steel<br>​
Aleks [24]

Answer:

b

Explanation:

a cpu is made from silicon chip

5 0
2 years ago
What is the device used for the calculations of payment and balancing the accounts record s​
Greeley [361]
A calculator or bank? Maybe an atm
6 0
1 year ago
Read 2 more answers
Mirrors on cars exist to
Ghella [55]

Answer:

Mirrors exist on cars so objects behind or to the side of the vehicle are brought into the driver's view. (such as cars, bicyclists, etc.) These spots are normally referred to as "blind spots", which are locations outside of the driver's peripheral vision that are difficult to see.

8 0
2 years ago
HELP PLEASEEEE!!!!!!!
Lubov Fominskaja [6]
This is too little points for a question I’m sorry.
8 0
2 years ago
Other questions:
  • Florida convicted __________ people of DUI in a one-year period from 2009 to 2010.
    15·1 answer
  • The negotiators past relationship will affect current behavior if the parties
    12·1 answer
  • Which of the following is true? A)Checks and Debit Cards both withdraw money directly from a bank account. B)Checks are the most
    13·2 answers
  • PLEASE HELP ME ASAP!!!!
    11·1 answer
  • Pseudocode is a good choice to communicate a____of a process
    10·1 answer
  • Choose the answer. Janice's IT department found that her computer had a program on it that was collecting her personal informati
    5·1 answer
  • Which of the following file formats cannot be imported using Get &amp; Transform?
    6·1 answer
  • Write a SELECT statement that returns one row for each musician that has orders with these columns:
    13·1 answer
  • Which word describes an important characteristic of good computer
    6·1 answer
  • QUESTION 44 To determine whether a character entered is a letter of the alphabet, use the ________ function. isdigit fromkeyboar
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!