Skip to content

usf-cs272-spring2022/homework-ArgumentParser-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ArgumentParser

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:

"-max", "false", "-min", "0", "-min", "-10", "hello", "-debug", "-f", "output.txt", "-verbose"

In this case, -max -min -debug -f and -verbose are all flags since they start with a - dash followed by at least 1 letter character. The values are false 0 hello and output.txt since they do not start with a - and letter character.

Note that -10 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 -max has value false. Flag -min has initial value 0, but the value get replaced by the second occurrence of the -min flag with the value -10 instead. The value hello has no associated flag and is ignored. The flags -debug and -verbose have no associated value, but are still stored. The resulting map should look similar to:

{
  "-max": "false",
  "-min": "-10",
  "-debug": null,
  "-f": "output.txt",
  "-verbose": null
}

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

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

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.

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.

About

ArgumentParser

Resources

Stars

Watchers

Forks

Languages