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]
3 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]3 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
Which block cipher mode of operating requires that both the message sender and receiver access a counter that computes a new val
ankoles [38]

There is block cipher kind of mode of operation. The block cipher mode of operating requires that both the message sender and receiver  is exchanged is the (CTR) Counter.

<h3>What is the Counter (CTR)?</h3>

This is known to be a common block cipher mode of operation. It often needs that both the message sender and receiver to have a kind of access a counter, that helps to computes a new value whenever a ciphertext block is been exchanged.

The disadvantage of CTR is known to be the fact that it needs a synchronous counter necessary for both the sender and receiver.

Learn more about  block cipher mode from

brainly.com/question/9979590

7 0
2 years ago
Consider the partially-filled array named a. What does the following loop do? (cin is a Scanner object)int[] a = {1, 3, 7, 0, 0,
boyakko [2]

Answer:

Option 1: May crash at runtime because it can input more elements than the array can hold

Explanation:

Given the code as follows:

  1.        int[] a = {1, 3, 7, 0, 0, 0};
  2.        int size = 3, capacity = 6;
  3.        int value = cin.nextInt();
  4.        while (value > 0)
  5.        {
  6.            a[size] = value;
  7.            size++;
  8.            value = cin.nextInt();
  9.        }

From the code above, we know the <em>a</em> is an array with six elements (Line 1). Since the array has been initialized with six elements, the capacity of the array cannot be altered in later stage.

However, a while loop is created to keep prompting for user input an integer and overwrite the value in the array started from index 3 (Line 4- 9). In every round of loop, the index is incremented by 1 (Line 7). If the user input for variable <em>value</em> is always above zero, the while loop will persist.  This may reach a point where the index value is out of bound and crash the program. Please note the maximum index value for the array is supposedly be 5.  

8 0
3 years ago
A customer has a system with a Gigabyte B450 Aorus Pro motherboard. He wants to upgrade the processor from the AMD Athlon X4 950
AleksandrR [38]
This upgrade will make a big improvement from his AMD Athalon X4 950 to the AMD Ryzen 7 2700X this is because the system will have more gigabytes and a better processor
3 0
3 years ago
Read 2 more answers
A _is a short descriptive label that you assign to webpages, photos,
Nitella [24]
Looks like you already answered your question? It’s the a tag ()
5 0
2 years ago
The part of a computer that provides access to the internet
guapka [62]

Answer:

Modem

Explanation:

A modem is a device that converts your data into a relevant format so that it can be used in the transmitting process from one computer to another one.

3 0
2 years ago
Other questions:
  • Ascending and descending are examples of
    5·2 answers
  • Can someone help me with...A table can help? PLEASE
    8·1 answer
  • 50 POINTS!!!!
    8·1 answer
  • •Should other states wait to see if the high-speed rail system works well before starting their own plans for similar systems?
    15·1 answer
  • A software development company wants to reorganize its office so that managers and the Computer Programmers they supervise can b
    13·2 answers
  • Explain the importance of mobile computing in communication​
    5·1 answer
  • Percentage-wise, which renewable energy source is used most?
    13·1 answer
  • Help plz, u just gotta select all that apply :)
    15·1 answer
  • How many times is the second for loop going to loop in this block of code? Write your answer in numeric form in the box provided
    6·1 answer
  • Task 2
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!