Added sting validator to Idevice
This commit is contained in:
1 parent
3a9473fda8
commit
c0050a6a31
2 files changed
+15
No files matched your search
@@ -53,6 +53,15 @@ public abstract class IDevice {
|
|||||||
return this.purpose;
|
return this.purpose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stringValidator checks if the string is within character
|
||||||
|
* bounds and if it is blank, null or empty.
|
||||||
|
* @param toBeValidated passes the string that needs to be validated.
|
||||||
|
* @param maxCharacterCount passes the maximum number of characters that can be accepted
|
||||||
|
* as an integer.
|
||||||
|
* @param minCharacterCount passes the minimum number of characters that can be accepted
|
||||||
|
* as an integer.
|
||||||
|
* */
|
||||||
public void stringValidator(String toBeValidated, int minCharacterCount, int maxCharacterCount) {
|
public void stringValidator(String toBeValidated, int minCharacterCount, int maxCharacterCount) {
|
||||||
if (toBeValidated == null) {
|
if (toBeValidated == null) {
|
||||||
throw new IllegalArgumentException("Value cannot be null");
|
throw new IllegalArgumentException("Value cannot be null");
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ package ca.bcit.comp2522.lab03;
|
|||||||
*/
|
*/
|
||||||
public class IPad extends IDevice {
|
public class IPad extends IDevice {
|
||||||
|
|
||||||
|
private final int MAX_OSVERSION_CHARACTERS = 10;
|
||||||
|
private final int MIN_OSVERSION_CHARACTERS = 1;
|
||||||
|
|
||||||
private final boolean hasCase;
|
private final boolean hasCase;
|
||||||
private final String OSVersion;
|
private final String OSVersion;
|
||||||
|
|
||||||
@@ -27,6 +30,9 @@ public class IPad extends IDevice {
|
|||||||
|
|
||||||
// TODO: validate String inputs
|
// TODO: validate String inputs
|
||||||
this.hasCase = hasCase;
|
this.hasCase = hasCase;
|
||||||
|
stringValidator(OSVersion,
|
||||||
|
MIN_OSVERSION_CHARACTERS,
|
||||||
|
MAX_OSVERSION_CHARACTERS);
|
||||||
this.OSVersion = OSVersion;
|
this.OSVersion = OSVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user