class Option {
        char optOption;
        String argument;
    }

    private final List<Option> options;
    private int current;
    private int optind;
    private final String[] argv;
    private final String opts;

    /**
     * Creates a new instance of Getopt.
     * @param argv argument vector
     * @param opts the list of allowed options
     */
    public Getopt(String[] argv, String opts) {
        options = new ArrayList<>();
        current = -1;
        optind = -1;
        this.argv = argv.clone();
        this.opts = opts;
    }

    /**
     * Parse the command line options.
     * @throws ParseException if an illegal argument is passed
     */
    public void parse() throws ParseException {<FILL_FUNCTION_BODY>


        int ii = 0;
        while (ii < argv.length) {
            char[] chars = argv[ii].toCharArray();
            if (chars.length > 0 && chars[0] == '-') {
                if (argv[ii].equals("--")) {
                    // End of command line options ;)
                    optind = ii + 1;
                    break;
                }

                for (int jj = 1; jj < chars.length; ++jj) {
                    int idx = opts.indexOf(chars[jj]);
                    if (idx == -1) {
                        throw new ParseException("Unknown argument: " + argv[ii].substring(jj), ii);
                    }

                    Option option = new Option();
                    option.optOption = chars[jj];
                    options.add(option);
                    // does this option take an argument?
                    if ((idx + 1) < opts.length() && (opts.charAt(idx + 1) == ':')) {
                        // next should be an argument
                        if ((jj + 1) < chars.length) {
                            // Rest of this is the argument
                            option.argument = argv[ii].substring(jj + 1);
                            break;
                        }
                        // next argument vector contains the argument
                        ++ii;
                        if (ii < argv.length) {
                            option.argument = argv[ii];
                        } else {
                            throw new ParseException("Option " + chars[jj] + " requires an argument", ii);
                        }
                    }
                }
                ++ii;
            } else {
                // End of options
                optind = ii;
                break;
            }
        }
    
<no_super_class>