Question: Language: JAVA Data/Input) Validation: Often the validation code has been duplicated. This time we have a requirement to try and stay as DRY as possible.
Language: JAVA
Data/Input) Validation:
Often the validation code has been duplicated. This time we have a requirement to try and stay as DRY
as possible. Thus, you will need to create a class called Validator which implements an interface as follows:
o The interface is called Acceptable you must create this interface and include it as part of your code. The interface will have the methods:
boolean isNonEmptyString (String s);
boolean isPositiveInput (double d);
o Your Validator class will implement this interface and define the methods to perform these checks.
o Your code will use your validator to do all the input validation such that the appropriate methods can simply be called and all the duplicated code will reside in the Validator class.
How can I create this. ( creating an online store and the input has to be positive and nonempty)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
