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) {
		
	}
	
}

@@ -179,33 +179,33 @@
 d encode(Pad pad
-f
+F
 ile, SourceFile 
@@ -231,16 +231,28 @@
 ) throws
+ InsufChars,
  PadNotD
@@ -261,20 +261,8 @@
 ined
-, InsufChars
  %7B%0A%09
@@ -311,48 +311,260 @@
 ;%0A%09%09
-boolean run = tru
+long index = 0;%0A%09%09boolean caps;%0A%0A%09%09// inform the pad file how many characters we will need%0A%09%09try %7B%0A%09%09%09padFile.reqLength(source.getFileSize());%0A%09%09%7D catch (PadNotDefined e) %7B%0A%09%09%09throw 
 e;%0A%09%09
+%7D%0A
 %0A%09%09
-do %7B%0A%09%09%09try
+// Keep reading source until eof is thrown%0A%09%09while (true)
  %7B%0A
-%09
 %09%09%09/
@@ -593,24 +593,33 @@
 source file%0A
+%09%09%09try %7B%0A
 %09%09%09%09inChar =
@@ -695,36 +695,63 @@
 ln(%22
-Source EOF Reached.%22);%0A%09%09%09%7D 
+Crypto.encode(): reached source EOF.%22);%0A%09%09%09%09break;%0A%09%09%09%7D
 %0A%09%09%09
@@ -762,32 +762,39 @@
 em.out.println(%22
+Crypto.
 encode(): source
@@ -792,43 +792,46 @@
 ): s
-ou
 rc
-e
 : %22 + 
+Character.toString(
 inChar)
+)
 ;%0A
-%09%09%09%09%0A%09%09%09try %7B%0A%09
+%0A
 %09%09%09/
@@ -861,16 +861,25 @@
 ad file%0A
+%09%09%09try %7B%0A
 %09%09%09%09padC
@@ -887,17 +887,17 @@
 ar = pad
-f
+F
 ile.getC
@@ -907,56 +907,8 @@
 ();%0A
-%09%09%09%7D catch (PadNotDefined e) %7B%09%09%09%09%0A%09%09%09%09throw e;%0A
 %09%09%09%7D
@@ -1008,17 +1008,17 @@
 aracters
-.
+!
 %22);%0A%09%09%09%09
@@ -1046,20 +1046,16 @@
 );%0A%09%09%09%7D%0A
-%09%09%09%0A
 %09%09%09Syste
@@ -1069,16 +1069,23 @@
 rintln(%22
+Crypto.
 encode()
@@ -1093,21 +1093,41 @@
  pad
+:
  %22 + 
+Character.toString(
 padChar)
 ;%0A%09%09
@@ -1126,38 +1126,20 @@
 har)
+)
 ;%0A
-%09%09%09
+%0A
 %0A%09%09%7D
- while (run);%09%09%09
 %0A%09%7D%0A
-%09
 %0A%09pu
@@ -1213,14 +1213,98 @@
 ) %7B%0A
-%09%09%0A%09%7D%0A%09
+%0A%09%7D%0A%0A%09private boolean isCaps(char c) %7B%0A%09%09if (c %3E= 'a')%0A%09%09%09return true;%0A%0A%09%09return false;%0A%09%7D%0A
 %0A%7D%0A

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