示例#1
0
            public static LunchClass ReadCSV(string csvLine)
            {
                string[] values = csvLine.Split(',');

                LunchClass l = new LunchClass();

                l.Name       = values[0];
                l.Type       = values[1].Split('/');
                l.Price      = values[2];
                l.Percentage = Convert.ToInt32(values[3]);
                return(l);
            }
示例#2
0
        static void Main(string[] args)
        {
            string            newLunchName   = "nothing";
            string            answer         = "";
            char              ans            = new char();
            int               amountSpending = 0;
            int               userType       = 0;
            List <string>     toldTypes      = new List <string>();
            List <string>     couldHave      = new List <string>();
            List <LunchClass> lunches        = File.ReadAllLines(FILEPATH + "lunchlist.csv").Skip(1).Select(l => LunchClass.ReadCSV(l)).ToList();

            toldTypes = GetTypes(lunches, toldTypes);
            Console.Write("-------Feeling Hungry?--------");

            Console.Write("\n\tGreat that's what I am here for!");
            Console.Write("\n\tDo you have a specific type of food in mind? (yes/no)");
            answer = Console.ReadLine();
            answer = answer.ToLower();
            ans    = answer[0];
            switch (ans)
            {
            case 'y':
                Console.Write("\n\tGood, this will make it easier...");
                Console.Write("\n\tHere is your current list of types to choose from:");
                do
                {
                    PrintList(toldTypes);
                    userType     = GetUserType(userType);
                    newLunchName = GetLunchByType(newLunchName, userType, amountSpending, toldTypes, lunches);
                    if (newLunchName == "nothing")
                    {
                        Console.Write("\n\tCouldn't find any restraunts of that type for that type...");
                        Console.Write("\n\tHere is your current list of types to choose from:");
                    }
                } while (newLunchName == "nothing");
                break;

            case 'n':
                Console.Write("\n\tNo problem, I can choose for you!");
                amountSpending = GetAmountSpending(amountSpending);
                couldHave      = GetPlacesOverAmount(amountSpending, lunches);
                newLunchName   = GetNewLunchName(newLunchName, couldHave);
                break;
            }
            Console.Write("\n\n\n Looks like we're going to: " + newLunchName + " for lunch today!");
            File.AppendAllText(FILEPATH + "previousLunches.txt", Environment.NewLine + newLunchName);

            Console.Read();
        }