answer.
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]
1 year 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]1 year 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
1.Which of the following class definitions defines a legal abstract class?a. class A { abstract void unfinished() { } }b. class
xxMikexx [17]

Answer:(c) abstract class A { abstract void unfinished(); }

Explanation:

A legal abstract class must have the keyword abstract before the class and an abstract class has abstract functions with the keyword abstract written and a void as the return type.

8 0
2 years ago
Sharon is thinking about opening a bakery. She knows she wants to set her own hours, reduce her stress and make a profit. But sh
hodyreva [135]
Please provide complete details.
4 0
1 year ago
Which type of styles can be applied to a word, phrase, or sentence?
Anna [14]

Answer:

I think the answer is going to be paragraph

6 0
1 year ago
Write an if-else statement to describe an integer. Print "Positive even number" if isEven and is Positive are both true. Print "
Nina [5.8K]

Answer:

C code explained below

Explanation:

#include <stdio.h>

#include <stdbool.h>

int main(void) {

int userNum;

bool isPositive;

bool isEven;

scanf("%d", &userNum);

isPositive = (userNum > 0);

isEven = ((userNum % 2) == 0);

if(isPositive && isEven){

  printf("Positive even number");

}

else if(isPositive && !isEven){

  printf("Positive number");

}

else{

  printf("Not a positive number");

}

printf("\n");

return 0;

}

6 0
1 year ago
(1) Prompt the user to enter two words and a number, storing each into separate variables. Then, output those three values on a
denpristay [2]

Answer:Prompt the user to enter two words and a number, storing each into separate variables. Then, output those three values on a single line separated by a space. (Submit for 1 point) Ex: If the input is: yellow Daisy 6 the output after the prompts is: You entered: yellow Daisy 6 Note: User input is not part of the program output. (2) Output two passwords using a combination of the user input. Format the passwords as shown below. (Submit for 2 points, so 3 points total). Ex: If the input is: yellow Daisy 6 the output after the prompts is: You entered: yellow Daisy 6 First password: yellow_Daisy Second password: 6yellow6 (3) Output the length of each password (the number of characters in the strings). (Submit for 2 points, so 5 points total). Ex: If the input is: yellow Daisy 6 the output after the prompts is: You entered: yellow Daisy 6 First password: yellow_Daisy Second password: 6yellow6 Number of characters in yellow_Daisy: 12 Number of characters in 6yellow6: 8

I have tried several different ways of doing this, but I keep getting an error on line 6

Explanation:

7 0
1 year ago
Other questions:
  • What are the two most important network-layer functions in a datagram network? what are the three most important network-layer f
    7·1 answer
  • Most GUIs provide all of the following except _____.
    12·2 answers
  • Suppose that you need to maintain a collection of data whose contents are fixed- i.e., you need to search for and retrieve exist
    8·1 answer
  • A key field is used to _____. enter a password uniquely identify records merge data list the most important information
    12·2 answers
  • Use the image below to answer this question.
    14·1 answer
  • Write a loop that counts the number of space characters in a string. Recall that the space character is represented as ' '.
    11·1 answer
  • Explain why Windows and Linux implements multiple locking mechanisms. Describe the circumstances under which they use spinlocks,
    13·1 answer
  • Show the stack with all activation record instances, including static and dynamic chains, when execution reaches position 1 in t
    10·1 answer
  • Sara is using her personal laptop (which is password protected) at a "hotspot" at a local cafe with wifi access. She is in the m
    7·1 answer
  • Problem 2 - K-Best Values - 30 points Find the k-best (i.e. largest) values in a set of data. Assume you are given a sequence of
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!