package com.azabani.java.rover;

import java.util.Stack;
import java.util.Iterator;

public class RoverController {
	RoverListList program;
	private Stack<Iterator<RoverCommand>> stack;

	private ConcreteComm comm;
	private ConcreteDriver driver;
	private ConcreteSoilAnalyser soilAnalyser;
	private ConcreteCamera camera;

	private CommObserver commObserver;
	private DriverObserver driverObserver;
	private SoilAnalyserObserver soilAnalyserObserver;
	private CameraObserver cameraObserver;

	public RoverController(
		ConcreteComm comm,
		ConcreteDriver driver,
		ConcreteSoilAnalyser soilAnalyser,
		ConcreteCamera camera
	) {
		program = new RoverListList();
		stack = new Stack<Iterator<RoverCommand>>();
		this.comm = comm;
		this.driver = driver;
		this.soilAnalyser = soilAnalyser;
		this.camera = camera;
		commObserver = new CommObserver(
			comm, this
		);
		driverObserver = new DriverObserver(
			driver, this
		);
		soilAnalyserObserver = new SoilAnalyserObserver(
			soilAnalyser, this
		);
		cameraObserver = new CameraObserver(
			camera, this
		);
	}
	public void start() {
		// TODO: write algorithm here
	}
	public void messageReceived(String message) {
		// TODO: write algorithm here
	}
	public void drivingAttempted(boolean success) {
		// TODO: write algorithm here
	}
	public void analysisReceived(String soilAnalysis) {
		// TODO: write algorithm here
	}
	public void photographReceived(char[] photoData) {
		// TODO: write algorithm here
	}
}

@@ -1173,37 +1173,88 @@
 %7B%0A%09%09
-// TODO: write algorithm here
+RoverCommandCodec c = new RoverCommandCodec();%0A%09%09program.add(c.decode(message));
 %0A%09%7D%0A

implement RoverController.messageReceived() (untested)