The License Plate Game (Assignment 2)

Overview

This is the first part in a multi-part programming assignment. The overall purpose of this assignment is to give you experience applying middleware patterns and frameworks by developing the license plate game, which is an educational way to pass the time during long car trips. This game works as follows:


Program Description

The initial assignment involves writing a simple C++ program that supports the following commands that help to automate the license plate game:

These commands can be invoked as follows: In the first part of the assignment, your license plate game program will read commands from standard input and display the results on the standard output. This first part is intended to be simple - it's primary purpose is to get you started with C++, OO design, and regular expressions. All of the software you write, however, will be reused in subsequent parts of this assignment, so it's important to understand them and get them right.

BTW, if you find it extremely hard to write this program, I recommend you take my Software Design course (CS 251) first since it focuses on the patterns and tactics of effective OO/C++ design and programming.


Regular Expressions

An easy way to check whether a word matches the current letter set is to use the POSIX regular expressions (regex) library. The function in this library are defined below:

NAME
     regcomp, regexec, regerror,  regfree  -  regular  expression matching

SYNOPSIS
     #include <sys/types.h>
     #include <regex.h>

     // Compile the regular expression contained in the string pointed
     // to by the pattern argument and place the results in the
     // structure pointed to by preg.
     int regcomp (regex_t *preg,       // The compiled pattern
                  const char *pattern, // The regex pattern
                  int cflags);         // Option flags (often 0)

     // Compares the null-terminated string specified by string with
     // the compiled regular expression.  preg must be initialized by
     // a previous call to regcomp(). 
     int regexec (const regex_t *preg, // The compiled pattern
                  const char *string,  // The subject string
                  size_t nmatch,       // The number of the match (usually 0)
                  regmatch_t pmatch[], // Vector that holds the nmatch elements (usually 0)
                  int eflags);         // Option flags (usually 0)

     // Provides a mapping from error codes returned by regcomp() and
     // regexec() to unspecified printable strings.
     size_t regerror (int errcode,
                      const regex_t *preg,  
                      char *errbuf, 
                      size_t errbuf_size);

     // Frees any memory allocated by regcomp() associated with preg.
     void regfree (regex_t *preg);

The manual page and example usage for the POSIX regex functions are available online. If you need to download a copy of this library for non-Linux platforms please see Perl-Compatible Regular Expression (PCRE) library, which is available online.


Concluding Remarks

I strongly encourage you to use and develop reusable C++ components based on the code you write. You will reuse these components throughout the course. If you are a graduate student, please implement this assignment using C++ Standard Template Library (STL) algorithms and containers.

Please see the online help for information on how to setup your development environment on Vanderbilt University's EECS computing system.