view defical-sharp/defical-cli/inputparser.cs @ 1:758381a85d76 default tip

Incorrect printf format.
author Edho Prima Arief <me@myconan.net>
date Mon, 28 Jun 2010 14:52:19 +0700
parents ebed2bd0d300
children
line wrap: on
line source

using System;

namespace defical_cli
{
    public partial class Program
    {
        private partial class main
        {
            private void getInput()
            {
                int min, def;
                if (graphType == "")
                {
                    while (true)
                    {
                        Console.Write("Available graph type:\n1. Wheel\n2. Fan\n3. Double Fan\nGraph type (default: 1): ");
                        if (!parseGraphType(Console.ReadKey().KeyChar))
                        {
                            Console.Write("\nInvalid graph type.\n");
                        }
                        else
                        {
                            Console.Write("\n");
                            break;
                        }
                    }
                }
                if (numVer == -1)
                {
                    while (true)
                    {
                        min = 5; def = 10;
                        Console.Write("Number of vertices (default: {0}): ", def);
                        if (!parseNum(Console.ReadLine(), min, def, out this.numVer))
                        {
                            Console.Write("Invalid number of vertices.\nPlease enter number with minimum of {0}.", min);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                if (numDef == -1)
                {
                    while (true)
                    {
                        min = 0; def = 2;
                        Console.Write("Number of deficiencies (default: {0}): ", def);
                        if (!parseNum(Console.ReadLine(), min, def, out this.numDef))
                        {
                            Console.Write("Please enter number (or press enter to use default).");
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                if (algorithm == "")
                {
                    while (true)
                    {
                        Console.Write("Available algorithm:\n1. Backtrack\nYour choice (default: 1): ");
                        if (!parseAlgo(Console.ReadKey().KeyChar))
                        {
                            Console.Write("\nInvalid algorithm.\n");
                        }
                        else
                        {
                            Console.Write("\n");
                            break;
                        }
                    }
                    Console.Write("\n");
                }
            }
        }
    }
}