/* * CS161: Programming Assignment P5 * Summer 2015 semester * Skeleton code provided by instructor for the CodeBreaker assignment. * Date: July 22, 2015 */ public class CodeBreaker { // constants defined for English. // You must use the constants and not the values in your program. public final int NUMBER_OF_LETTERS = 26; // knownFrequencies stores the results obtained from the training data. // Each element stores the known frequency of the corresponding letter. private double[] knownFrequencies = new double[NUMBER_OF_LETTERS]; // No constructor to be defined. Uses default constructor // This method is needed only for testing that you got the // correct array of known frequency values. // Helps with grading and awarding partial credit. public double[] getKnownFrequencies() { // fill in this code } // This method is needed for testing to bypass the training method while // testing decryption functionality in case your training method isn't // working correctly. Helps with grading and providing partial credit. public void setKnownFrequencies(double[] knownFrequencies) { // fill in this code } // Implements the training step. Sets the array knownFrequencies public void train(String trainingFileName) { // fill in this code } // Decrypts the contents of the file referred to by cipherTextFileName, // and produces an output file called outputFileName, which contains the // decrypted text using the decryption algorithm in the Caesar cipher. // Returns that the value of shift that was used in the Caesar cipher. public int decrypt(String cipherTextFileName, String outputFileName) { } // barebones main method to test your code public static void main(String[] args) { CodeBreaker cb = new CodeBreaker(); cb.train("sample.txt"); cb.decrypt("encrypt-output.txt", "codebreaker-output.txt"); // File encrypt-output.txt should be created if you run // the main method I provided for the Sentry class. // File codebreaker-output.txt will get // created as a result of your decrypt method. } }