Skip to content

usf-cs212-spring2021/homework-ArgumentMap-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ArgumentMap

Points

For this homework, you will create a class to parse command-line arguments and store them in a map. For example, consider the following command-line arguments:

"-a", "ant", "-b", "bee", "-b", "bat", "cat", "-d", "-e", "elk", "-f"

In this case, -a -b -d -e and -f are all flags since they start with a - dash followed by at least 1 letter character. The values are ant bee bat cat and elk since they do not start with a - and letter character.

Note that -42 is not a flag because the - dash is followed by a digit character. Instead it should be interpreted as a value representing a negative number.

Not all flags have values, not all values have associated flags, and values will be overwritten if there are repeated flags. For example, flag -a has value ant. Flag -b has initial value bee, but the value get replaced by the second occurrence of the -b flag with the value bat instead. The value cat has no associated flag and is ignored. The flags -d and -f have no associated value, but are still stored by the argument parser. The resulting map should look similar to:

{
  "-a" = "ant",
  "-b" = "bat",
  "-d" = null,
  "-e" = "elk",
  "-f" = null
}

Use an appropriate data structure to store the key/value pairs. The key/value pairs does not need to be stored in sorted order.

Avoid looping more often than necessary. For example, numFlags() should not require a loop.

Requirements

See the Javadoc and TODO comments in the template code in the src/main/java directory for additional details. You must pass the tests provided in the src/test/java directory. Do not modify any of the files in the src/test directory.

See the Homework Guides for additional details on homework requirements and submission.

Hints

Below are some hints that may help with this homework assignment:

These hints are optional. There may be multiple approaches to solving this homework.

Releases

No releases published

Packages

No packages published

Languages