/*
 *
 *
 *
 *
 */

package com.hearthattack;

//add imports

import com.protos.PlayerModelProto;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.atomic.AtomicBoolean;
import java.lang.Runnable;
import java.io.*;


public class Reader implements Runnable {
  private PlayerModelProto playerModel;
  private PlayerModelProto opponentModel;
  private AtomicBoolean update;
  private AtomicBoolean terminate;
  private Lock write;

  public Reader(PlayerModelProto sharedPlayer, PlayerModelProto sharedOpponent, AtomicBoolean sharedFlag,
				AtomicBoolean sharedTerm, ReentrantReadWriteLock rwLock) {
    playerModel = sharedPlayer;
	opponentModel = sharedOpponent;
    update = sharedFlag;
    terminate = sharedTerm;
    write = rwLock.writeLock();
  }

  public void run() {
	try {
	  FileInputStream istream = new FileInputStream("Parser.log");
	  while(!terminate.get()){
		while(!istream.available()); //wait for new data in stream
		  playerModel = PlayerModelProto.parseFrom(istream);
		  opponentModel = PlayerModelProto.parseFrom(istream);
		  write.lock();
			update.set(true);
			write.unlock();
	  }
	}
	catch (FileNotFoundException e) {
		System.out.println("Unable to open file");
	}
	catch (IOException e) {
		e.printStackTrace();
	}
  }
}
@@ -1,22 +1,107 @@
 /
-*%0A *%0A *%0A *%0A *%0A */
+/Runs concurrently with Handler class, parses PlayerModelProto.PlayerModel object from FileInputStream
 %0A%0Apa
@@ -129,23 +129,8 @@
 k;%0A%0A
-//add imports%0A%0A
 impo
@@ -425,16 +425,28 @@
 delProto
+.PlayerModel
  playerM
@@ -477,16 +477,28 @@
 delProto
+.PlayerModel
  opponen
@@ -593,16 +593,39 @@
 k write;
+%0A  private String path;
 %0A%0A  publ
@@ -646,24 +646,36 @@
 erModelProto
+.PlayerModel
  sharedPlaye
@@ -693,16 +693,28 @@
 delProto
+.PlayerModel
  sharedO
@@ -752,12 +752,24 @@
 ag,%0A
-%09%09%09%09
+                
 Atom
@@ -819,16 +819,33 @@
 k rwLock
+, String filePath
 ) %7B%0A    
@@ -872,17 +872,20 @@
 Player;%0A
-%09
+    
 opponent
@@ -993,16 +993,37 @@
 Lock();%0A
+    path = filePath;%0A
   %7D%0A%0A  p
@@ -1045,16 +1045,22 @@
 ) %7B%0A
-%09
+    
 try %7B%0A
-%09
+    
   Fi
@@ -1107,24 +1107,19 @@
 eam(
-%22Parser.log%22);%0A%09
+path);%0A    
   wh
@@ -1145,17 +1145,22 @@
 ))%7B%0A
-%09%09
+        
 while(
-!
 istr
@@ -1174,16 +1174,20 @@
 ilable()
+ %3E 0
 ); //wai
@@ -1211,18 +1211,24 @@
  stream%0A
-%09%09
+        
   player
@@ -1244,32 +1244,44 @@
 layerModelProto.
+PlayerModel.
 parseFrom(istrea
@@ -1284,18 +1284,24 @@
 tream);%0A
-%09%09
+        
   oppone
@@ -1327,16 +1327,28 @@
 elProto.
+PlayerModel.
 parseFro
@@ -1359,18 +1359,24 @@
 tream);%0A
-%09%09
+        
   write.
@@ -1383,19 +1383,26 @@
 lock();%0A
-%09%09%09
+          
 update.s
@@ -1415,11 +1415,18 @@
 e);%0A
-%09%09%09
+          
 writ
@@ -1441,17 +1441,49 @@
 ();%0A
-%09  %7D%0A%09%7D%0A%09
+      %7D%0A      istream.close();%0A    %7D%0A    
 catc
@@ -1512,18 +1512,22 @@
 on e) %7B%0A
-%09%09
+      
 System.o
@@ -1565,12 +1565,18 @@
 %22);%0A
-%09%7D%0A%09
+    %7D%0A    
 catc
@@ -1599,10 +1599,14 @@
 ) %7B%0A
-%09%09
+      
 e.pr
@@ -1626,12 +1626,16 @@
 ();%0A
-%09
+    
 %7D%0A  %7D%0A%7D
+%0A

Update Reader.java