package ca.vire.otp;

import java.io.EOFException;
import ca.vire.otp.exception.PadNotDefined;
import ca.vire.otp.exception.InsufChars;

public class Crypto {

	public static void encode(Pad padfile, SourceFile source, LogFile log) throws PadNotDefined, InsufChars {
		char inChar = 0, padChar = 0, outChar = 0;
		boolean run = true;
		
		do {
			try {
				// Get a char from the source file
				inChar = source.getChar();
			} catch (EOFException e) {
				System.out.println("Source EOF Reached.");
			} 
			System.out.println("encode(): source: " + inChar);
				
			try {
				// Get a char from the pad file
				padChar = padfile.getChar();
			} catch (PadNotDefined e) {				
				throw e;
			} catch (EOFException e) {
				System.out.println("Crypto.encode(): pad file has run out of characters.");
				throw new InsufChars();
			}
			
			System.out.println("encode(): pad " + padChar);
			
		} while (run);			
	}
	
	public static void decode(Pad padfile, SourceFile source, LogFile log) {
		
	}
	
}

package ca.vire.otp;

import java.io.EOFException;
import ca.vire.otp.exception.PadNotDefined;
import ca.vire.otp.exception.InsufChars;

public class Crypto {

	public static void encode(Pad padFile, SourceFile source, LogFile log) throws InsufChars, PadNotDefined {
		char inChar = 0, padChar = 0, outChar = 0;
		long index = 0;
		boolean caps;

		// inform the pad file how many characters we will need
		try {
			padFile.reqLength(source.getFileSize());
		} catch (PadNotDefined e) {
			throw e;
		}

		// Keep reading source until eof is thrown
		while (true) {
			// Get a char from the source file
			try {
				inChar = source.getChar();
			} catch (EOFException e) {
				System.out.println("Crypto.encode(): reached source EOF.");
				break;
			}
			System.out.println("Crypto.encode(): src: " + Character.toString(inChar));

			// Get a char from the pad file
			try {
				padChar = padFile.getChar();
			} catch (EOFException e) {
				System.out.println("Crypto.encode(): pad file has run out of characters!");
				throw new InsufChars();
			}
			System.out.println("Crypto.encode(): pad: " + Character.toString(padChar));


		}
	}

	public static void decode(Pad padfile, SourceFile source, LogFile log) {

	}

	private boolean isCaps(char c) {
		if (c >= 'a')
			return true;

		return false;
	}

}

rewrite of crypto, not yet finished. plenty of debug output placed everywhere