Question: public SomeMap () { this.map = new HashMap (); } // Determines whether the argument is a flag. Flags start with a dash - character,
public SomeMap() {
this.map = new HashMap
}
// Determines whether the argument is a flag. Flags start with a dash "-" character, followed by at least one other non-whitespace character.
public static boolean isFlag(String arg) {
if (arg.length() >= 2)
{
if (arg.startsWith("-") && !(arg.isEmpty()))
{
return true;
}
}
return false;
}
//Issue: doesn't return false for null, need to fix that
public static boolean isValue(String arg) {
return !arg.startsWith("-") && !arg.trim().isEmpty();
}
//likewise with null
/**
* Determines whether the specified flag exists.
*
* @param flag the flag to search for
* @return {@code true} if the flag exists
*/
public boolean hasFlag(String flag) {
return false;
}
/**
* Determines whether the specified flag is mapped to a non-null value.
* @param flag the flag to search for
* @return {@code true} if the flag is mapped to a non-null value
*/
public boolean hasValue(String flag) {
return false;
}
/**
* Returns the value to which the specified flag is mapped as a
* {@link String}, or null if there is no mapping for the flag
* @param flag the flag whose associated value is to be returned
* @return the value to which the specified flag is mapped, or {@code null} if there is no mapping for the flag */
public String getString(String flag) {
return null;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
