/** * Author: Josiah Yoder et al. * Class: SE1011-011 * Date: 11/7/13 8:43 AM * Lesson: Week 7, Day 1 */ /* * WARNING * * THE ENCRYPTION ALGORITHM IMPLIED BY THIS EXAMPLE * IS INCREDIBLY EASY TO BREAK. * * DO NOT USE IT WITH REAL DATA. */ public class RandomFun011_9_3 { int[] randomValues; public RandomFun011_9_3() { randomValues = generateLookupTable(); } public int[] generateLookupTable() { // TODO: implement this method! return null; } public String askForData() { // TODO: implement this method! return null; } // Will use the instance variable randomValues public int[] encryptData(String input) { // TODO: implement this method! return null; } public static void main() { // Top-down approach: // Write method descriptions first, then implementations. // // This is the class version. // // See RandomStatic011_9_3 for an inferior top-level implementation // that doesn't take advantage of OO concepts. RandomFun011_9_3 fun = new RandomFun011_9_3(); String input = fun.askForData(); int[] encryptedResult = fun.encryptData(input); // We can eliminate an argument because it is an instance variable. // (The eliminated argument is randomValues). // // We could make "input" an instance variable, too, // but it is only needed in this method, so it is clearer // to just pass it from one method to the next, // making it clear where the data comes from and where it goes. // That is, we are making the flow of data clear. // // This way, it is easy to encrypt some more input if we // want to, like this: String moreInput = fun.askForData(); int[] moreEyncryptedData = fun.encryptData(moreInput); } }