Example #1
0
        static SelectableOptions GetChoiceFromUser()
        {
            // TODO: This should be a Console.ReadLine
            Console.Write("Ange ditt val: ");
            string            input      = Console.ReadLine();
            int               inputAsInt = Convert.ToInt32(input);
            SelectableOptions option     = (SelectableOptions)inputAsInt;
            bool              exists     = Enum.IsDefined(typeof(SelectableOptions), option);

            return(option);
        }
Example #2
0
        static void Main(string[] args)
        {
            List <ISavableToDatabase> listOfThingsToCreate = new List <ISavableToDatabase>();
            Animal theAnimalToCreate;

            Console.WriteLine("Make a choice to create: [" + Convert.ToInt32(SelectableOptions.CreateAFox) + "] for Fox [" + Convert.ToInt32(SelectableOptions.CreateAElk) + "] for Elk and [" + Convert.ToInt32(SelectableOptions.CreateAWolf) + "] for Wolf");
            SelectableOptions choice = GetChoiceFromUser();

            switch (choice)
            {
            case SelectableOptions.CreateAElk:
                Console.WriteLine("You selected to create an Elk");
                theAnimalToCreate = new Elk();
                break;

            case SelectableOptions.CreateAWolf:
                Console.WriteLine("You selected Wolf");
                theAnimalToCreate = new Wolf();
                break;

            case SelectableOptions.CreateAFox:
                Console.WriteLine("You selected Fox");
                theAnimalToCreate = new Fox();
                break;

            default:
                Console.WriteLine("No selection, you get an Elk!");
                break;
            }

            // NOTE: Commented out code for clarity
            // if (theAnimalToCreate is ISavableToDatabase) {
            //  listOfThingsToCreate.Add(theAnimalToCreate as ISavableToDatabase);
            // }

            // foreach(ISavableToDatabase creatableThing in listOfThingsToCreate) {
            //  creatableThing.SaveToDatabase();
            // }

            Console.WriteLine("End of selection program");
        }
Example #3
0
///<summary>
///Creates a new instance of Selectable
///</summary>
public Selectable(JsString selector, SelectableOptions options)
{
Selector = J(selector);
Selector.selectable(options);
}