/*
 * 2004 Utah High School Programming Contest, University of Utah
 * Take-Home Problem
 *
 * Puzzle.hpp
 *
 * This file contains the definition of the Puzzle class.
 */

#ifndef PUZZLE_HPP
#define PUZZLE_HPP

#include "Cipher.hpp"
#include "Dictionary.hpp"

#include <string>
#include <vector>

using namespace std;

/**
 * A Puzzle collects the "input" information about a cryptogram puzzle and
 * evaluates possible solutions (i.e., decryption ciphers).  The most important
 * input data is the cryptogram text, of course, but a Puzzle may also use
 * other sources of information such as a dictionary of known English words.
 * The primary job of a Puzzle object is to evaluate ciphers that are given to
 * it: in other words, to decide how likely it is that a given cipher is the
 * right cipher.
 */
class Puzzle {
private:
    /**
     * The encrypted message.
     */
    const string cryptogram;
    
    /**
     * The words within the cryptogram, organized as a vector of strings.
     * The contents of this vector are initialized by the Puzzle constructor.
     */
    vector<string> cryptogram_words;
    
    /**
     * The Dictionary of known words.  This is used to evaluate the quality
     * of ciphers.
     */
    const Dictionary& dict;
    
public:
    /**
     * Construct a Puzzle object to represent a cryptogram decryption problem.
     * The information for a puzzle includes the cryptogram itself and a
     * dictionary of English words.
     *
     * @param the_cryptogram    the string containing the cryptogram text
     * @param the_dict          the Dictionary of known English words
     */
    Puzzle(const string& the_cryptogram, const Dictionary& the_dict);
    
    /**
     * Destroy a Puzzle object.
     */
    virtual ~Puzzle();
    
    /**
     * Test the given Cipher object to see how well it decrypts this Puzzle's
     * cryptogram.  This method returns the "score" of the cipher, which is a
     * measure of how well the cipher decrypts the message.  The better the
     * cipher, the higher the score.
     *
     * @param cipher    the Cipher to be tested
     * @return          the score for the cipher
     */
    virtual int test_cipher(const Cipher& cipher) const;
};

#endif // PUZZLE_HPP

// End of file.

