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

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) {
		RoverCommandCodec c = new RoverCommandCodec();
		program.add(c.decode(message));
	}
	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
	}
}

implement RoverController.messageReceived() (untested)