コード例 #1
0
        static void Main(string[] args)
        {
            WineItem myWineItem = new WineItem();

            //3964 is the number of current items in the list
            //Create an array of type WineItem to hold a bunch of wineItems
            WineItem[] wineItems = new WineItem[3964];

            //call CSV Processor to Load File while allowing user to choose the file
            Console.WriteLine("What is the name of the CSV file that you would like to load?");
            String pathToCsvFile = Console.ReadLine();

            ImportCSV(pathToCsvFile, wineItems);

            //Instantiate a new UI Class to call methods after processing CSV File and reading contents.
            userInterface ui = new userInterface();

            IList <WineItem> collectionOfWine = new List <WineItem>(wineItems);



            //Get users input choice
            int choice = ui.GetUserInput();

            while (choice != 4)
            {
                //If the chioce they made is 1, Print the entire list of wine items
                if (choice == 1)
                {
                    //Create a string to concat the output
                    string allOutput = "";

                    //Loop through all the wine Items to concat them together.
                    foreach (WineItem wine in wineItems)
                    {
                        if (wine != null)
                        {
                            allOutput += wine.ToString() +
                                         Environment.NewLine;
                        }
                    }
                    //Once the concat is done, have the UI class print out the result
                    ui.PrintAllOutput(allOutput);
                }

                //If the choice they made is 2, search for item id provided by user and if found print it out
                if (choice == 2)
                {
                    collectionOfWine.Add(myWineItem);
                }
                //If the choice they made is 3, allow user to add a new wine item to the list
                if (choice == 3)
                {
                }

                //Get the next choice from the user.
                choice = ui.GetUserInput();
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {

            WineItem myWineItem = new WineItem();

            //3964 is the number of current items in the list
            //Create an array of type WineItem to hold a bunch of wineItems
            WineItem[] wineItems = new WineItem[3964];

            //call CSV Processor to Load File while allowing user to choose the file
            Console.WriteLine("What is the name of the CSV file that you would like to load?");
            String pathToCsvFile = Console.ReadLine();
            ImportCSV(pathToCsvFile, wineItems);

            //Instantiate a new UI Class to call methods after processing CSV File and reading contents.
            userInterface ui = new userInterface();
            
            IList<WineItem> collectionOfWine = new List<WineItem>(wineItems);






            //Get users input choice
            int choice = ui.GetUserInput();
            while (choice != 4)
            {
                //If the chioce they made is 1, Print the entire list of wine items
                if (choice == 1)
                {
                    
                    //Create a string to concat the output
                    string allOutput = "";

                    //Loop through all the wine Items to concat them together.
                    foreach (WineItem wine in wineItems)
                    {
                        if (wine != null)
                        {
                            allOutput += wine.ToString() +
                                        Environment.NewLine;
                        }
                    }
                    //Once the concat is done, have the UI class print out the result
                    ui.PrintAllOutput(allOutput);
                }

                //If the choice they made is 2, search for item id provided by user and if found print it out
                if (choice == 2)
                {
                    collectionOfWine.Add(myWineItem);
                }
                //If the choice they made is 3, allow user to add a new wine item to the list
                if (choice == 3)
                {

                }
                
                //Get the next choice from the user.
                choice = ui.GetUserInput();
            }
        }