1.4-Software-Development-Principles

Generics

Creating a Generic OptionSelector

During the module OGP you created an OptionSelector in week 3. The problem with that implementation is that it only works for a simple type. To use it for another type you would have to rebuild your code.

Think what you can do with a generic type.

public class OptionSelector<T> {
	public void addOption(T option);
	public void printMenu(boolean showQuit);
	public T selectOption();
}

Assignment