package de.mrunde.bachelorthesis.instructions;

import com.mapquest.android.maps.GeoPoint;

import de.mrunde.bachelorthesis.basics.Landmark;

/**
 * This is a "global landmark"-based instruction.
 * 
 * @author Marius Runde
 */
public class GlobalInstruction extends Instruction {

	/**
	 * The global landmark along the route
	 */
	private Landmark global;

	/**
	 * Constructor of the GlobalInstruction class
	 * 
	 * @param instructionPoint
	 *            The point where the instruction should be spoken
	 * @param global
	 *            The global landmark along the route
	 */
	public GlobalInstruction(GeoPoint instructionPoint, Landmark global) {
		super(instructionPoint, 0);
		this.global = global;
	}

	/**
	 * @return The instruction as a verbal text
	 */
	public String toString() {
		String instruction = "You will pass ";
		String category = this.global.getFormattedCategory();
		if (category.startsWith("a") || category.startsWith("e")
				|| category.startsWith("i") || category.startsWith("o")
				|| category.startsWith("u")) {
			instruction = "an " + category + " soon";
		} else {
			instruction = "a " + category + " soon";
		}
		return instruction;
	}

	/**
	 * @return The extended instruction as a verbal text which uses the title of
	 *         the landmark instead of its category
	 */
	public String toExtendedString() {
		String instruction = "You will pass ";
		String title = this.global.getTitle();
		if (title.startsWith("a") || title.startsWith("e")
				|| title.startsWith("i") || title.startsWith("o")
				|| title.startsWith("u")) {
			instruction = "an " + title + " soon";
		} else {
			instruction = "a " + title + " soon";
		}
		return instruction;
	}

	/**
	 * @return The global landmark along the route
	 */
	public Landmark getGlobal() {
		return this.global;
	}
}

@@ -1086,32 +1086,33 @@
 %0A%09%09%09instruction 
++
 = %22an %22 + catego
@@ -1145,32 +1145,33 @@
 %0A%09%09%09instruction 
++
 = %22a %22 + categor
@@ -1633,24 +1633,25 @@
 instruction 
++
 = %22an %22 + ti
@@ -1693,16 +1693,17 @@
 ruction 
++
 = %22a %22 +

Fix error of verbal output for GlobalInstruction