Exemplo n.º 1
0
        // SWITCH STATEMENT TO HANDLE USER INPUT FOR MENU OPTIONS
        static void SelectionHandler()
        {
            switch (userSelection)
            {
                case 1:
                    // LOADS CSV FILE
                    CSVProcessor process = new CSVProcessor();
                    break;
                case 2:

                    break;
                case 3:
                    
                    break;
                case 4:
                    // CLEAR TERMINAL SCREEN
                    Console.Clear();

                    // DISPLAYS A LIST OF WINE ITEMS TO TERMINAL
                    WineItemCollection.ListItems();
                    break;
                case 5:
                    // TERMINATES THE APPLICATION
                    Environment.Exit(0);
                    break;
            }
        }
        //Prompts the user to enter an ID, Description, and Pack Size for the item being added to the list.
        //Displays a message if the item was successfully added to the list.
        //Displays a message if the item was NOT successfully added to the list.
        public Int32 UserAddWine(WineItem[] wineItems, Int32 location)
        {
            Console.Clear();
            Console.WriteLine("Enter the ID you wish to add to the wine directory: ");
            Console.WriteLine();
            String temp1 = Console.ReadLine();

            Console.WriteLine();
            Console.WriteLine("Enter the Description you wish to add to the wine directory: ");
            Console.WriteLine();
            String temp2 = Console.ReadLine();

            Console.WriteLine();
            Console.WriteLine("Enter the Pack Size you wish to add to the wine directory: ");
            Console.WriteLine();
            String temp3 = Console.ReadLine();

            Console.WriteLine();
            if (temp1 != "" && temp2 != "" && temp3 != "")
            {
                String[] Temp = { temp1, temp2, temp3 };
                CSVProcessor.AddToArray(wineItems, location, Temp);
                Console.WriteLine("Your item has been successfully added to the wine directory!");
                Console.WriteLine();
                location++;
            }
            else
            {
                Console.WriteLine("There seems to be an issue with adding your item to the wine directory.");
                Console.WriteLine();
            }
            return(location);
        }
Exemplo n.º 3
0
        public void WineCSV(string CSVFile, WineItem[] Winelist)
        {
            StreamReader streamreader = null;

            try
            {
                string line;


                streamreader = new StreamReader(CSVFile);


                int i = 0;


                while ((line = streamreader.ReadLine()) != null)
                {
                    CSVProcessor.processLine(line, Winelist, i++);
                }
            }


            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            finally
            {
                if (streamreader != null)
                {
                    streamreader.Close();
                }
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            UserInterface userInterface = new UserInterface();
            CSVProcessor csvProcessor = new CSVProcessor();
            //WineItemCollection WineitemCollection = new WineItemCollection(CSVProcessor(string[400] WineArray));

            userInterface.MenuOptions();    //Displays user options
            userInterface.Choices();        //Allows user to select an option
        }
Exemplo n.º 5
0
 static void Main(string[] args)
 {
     //Initializes Each of the other classes
     CSVProcessor onlyRunOneCSVProcessor = new CSVProcessor(upPath(3,Environment.CurrentDirectory) + "\\datafiles\\WineList.csv");
     wineItemCollection theWineCollection = new wineItemCollection(onlyRunOneCSVProcessor);
     controlClass controlTheProgram = new controlClass(theWineCollection, onlyRunOneCSVProcessor);
     //repeats the ui
     while(true)
     {
         controlTheProgram.PrintPrompt();
     }
 }
Exemplo n.º 6
0
        public void Option1()
        {
            if(!fileRead)
                {
                    CSVProcessor csvProcessor = new CSVProcessor();
                    Console.WriteLine("Hello");

                }
                else
                {
                    Console.WriteLine("The file has already been loaded.");
                }
        }
        /// <summary>
        /// Base Constructor to run program.
        /// </summary>
        public RunProgram()
        {
            wineItem = new WineItem();
            runProgramBool = true;
            processFiles = new CSVProcessor();
            loadListSizeInt = processFiles.LoadListSize;
            wineItemCollection = new WineItemCollection(loadListSizeInt);
            mainMenu = new UserInterface();

            wineItem = new WineItem();
            while (runProgramBool)
            {
                mainMenu.PrintUserMenu();
                UserSelection();
            }
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            //Make a Menu object of UserInterface class
            UserInterface Menu = new UserInterface();

            //make a WineFile object of CSVProecessor class
            CSVProcessor WineFile = new CSVProcessor();

            //instantiate a list object of the WineItem class
            List <WineItem> wineList = new List <WineItem>();

            // call the DisplayMainMenu method from Menu object, passing WineFile object and wineList list object
            Menu.DisplayMainMenu(WineFile, wineList);

            // call the DisplaySubMenu method from Menu object, passing wineList list object
            Menu.DisplaySubMenu(wineList);
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            //Make a Menu object of UserInterface class
            UserInterface Menu = new UserInterface();

            //make a WineFile object of CSVProecessor class
            CSVProcessor WineFile = new CSVProcessor();

            //instantiate a list object of the WineItem class
            List<WineItem> wineList = new List<WineItem>();

            // call the DisplayMainMenu method from Menu object, passing WineFile object and wineList list object
            Menu.DisplayMainMenu(WineFile, wineList);

            // call the DisplaySubMenu method from Menu object, passing wineList list object
            Menu.DisplaySubMenu(wineList);
        }
Exemplo n.º 10
0
       static void Main(string[] args)
        {
            Console.WriteLine("Welcome to our wacky and wild wine list! \n");

            int UserIn = UserInterface.GetUserInput();

            // Assuming GetUserInput returns an integer of input
            // Well it still wants an integer?
            // Needed an extra = so it wasnt an assignment
            if (UserIn == 1)
            {
                // reading in the .CSV file
                // Find it using ../../../datafiles

                CSVProcessor csvProcessr = new CSVProcessor();


                //Dont know why this isnt working?
                csvProcessr.ImportCSV("../../../datafiles.csv", allTheWines);
            }
            else if (UserIn == 2)
            {
                // add to the list
                // use a method created in the WineItemCollection

                Console.WriteLine(" We will now add a new Item to the list!");
            }
            else if (UserIn == 3)
            {
                // loop through the array by the first index of a newly created WineItem with the input
                // as the first index and when they == each other
                // print out that array
                Console.WriteLine(" We will now look for an ID in the list!");
            }
            else if (UserIn == 4)
            {
                Console.WriteLine(" We will see you later! ");

                Environment.Exit(0);
            }


            }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            WineItemCollection wineItemCollection = new WineItemCollection();                        //instanciate WineItemCollection class

            CSVProcessor csvProcessor = new CSVProcessor();                                          //instanciate CSVProcessor class

            csvProcessor.ImportCSV("../../../datafiles/WineList.csv", wineItemCollection.WineItems); //determine path of the CSV file

            UserInterface ui = new UserInterface();                                                  //instanciate UserInterface class

            int choice = ui.FilePrompt();                                                            //integer to determine which number the user chooses when the interface gives its prompt

            while (choice.ToString() != "4")                                                         //runs intil the user chooses 4, which closes the program
            {
                switch (choice)                                                                      //switch statement to determine what course of action to take, depending on how to user responds to the interface
                {
                case 1:                                                                              //case 1 prints the entire wine array
                    wineItemCollection.WineItemsProcessed = 0;                                       //resets the integer so it won't accumulate with itself if the user prints the wine list more than once
                    wineItemCollection.PrintWineList();                                              //prints the wine list
                    Console.WriteLine();                                                             //inputs a blank line
                    choice = ui.FilePrompt();                                                        //reprompts the user to select an action from the interface
                    break;

                case 2:                                         //case 2 allows the user to search for a wine by its ID
                    wineItemCollection.SearchWineList();        //method to search the entire wine list
                    Console.WriteLine();                        //inputs a blank line
                    choice = ui.FilePrompt();                   //reprompts the user to select an action from the interface
                    break;

                case 3:
                    wineItemCollection.AddWineToList();
                    Console.WriteLine();
                    choice = ui.FilePrompt();
                    break;

                default:                                                            //default case that will only run if the user chooses an invalid response to the interface
                    Console.WriteLine("Error. Please select a valid option.");      //the user is told their response is invalid
                    Console.WriteLine();                                            //inputs a blank line
                    choice = ui.FilePrompt();                                       //reprompts the user to select an action from the interface
                    break;
                }
            }
        }
Exemplo n.º 12
0
        // Display the main menu for the user.
        public void DisplayMainMenu(CSVProcessor WineFile, List <WineItem> wineList)
        {
            bool quitMainBoolean = false;

            // do while loop keeps showing the menu
            do
            {
                Console.WriteLine("Select an option: \n \n 1. Load the csv file of wine list.  2. Exit program.");
                string optionSelection = Console.ReadLine();

                if (optionSelection == "1")
                {
                    quitMainBoolean = true;
                    WineFile.ReadCSV(wineList);
                }
                else if (optionSelection == "2")
                {
                    Environment.Exit(0);
                }
            } while (quitMainBoolean != true);
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            WineItemCollection wineItemCollection = new WineItemCollection();    //instanciate WineItemCollection class

            CSVProcessor csvProcessor = new CSVProcessor();     //instanciate CSVProcessor class

            csvProcessor.ImportCSV("../../../datafiles/WineList.csv", wineItemCollection.WineItems);   //determine path of the CSV file

            UserInterface ui = new UserInterface();     //instanciate UserInterface class

            int choice = ui.FilePrompt();   //integer to determine which number the user chooses when the interface gives its prompt
            while (choice.ToString() != "4")    //runs intil the user chooses 4, which closes the program
            {
                switch (choice) //switch statement to determine what course of action to take, depending on how to user responds to the interface
                {
                    case 1:                                         //case 1 prints the entire wine array
                        wineItemCollection.WineItemsProcessed = 0;  //resets the integer so it won't accumulate with itself if the user prints the wine list more than once
                        wineItemCollection.PrintWineList();         //prints the wine list
                        Console.WriteLine();                        //inputs a blank line
                        choice = ui.FilePrompt();                   //reprompts the user to select an action from the interface
                        break;
                    case 2:                                     //case 2 allows the user to search for a wine by its ID
                        wineItemCollection.SearchWineList();    //method to search the entire wine list
                        Console.WriteLine();                    //inputs a blank line
                        choice = ui.FilePrompt();               //reprompts the user to select an action from the interface
                        break;
                    case 3:
                        wineItemCollection.AddWineToList();
                        Console.WriteLine();
                        choice = ui.FilePrompt();
                        break;
                    default:                                                        //default case that will only run if the user chooses an invalid response to the interface
                        Console.WriteLine("Error. Please select a valid option.");  //the user is told their response is invalid
                        Console.WriteLine();                                        //inputs a blank line
                        choice = ui.FilePrompt();                                   //reprompts the user to select an action from the interface
                        break;
                }
            }
        }
        // Display the main menu for the user.
        public void DisplayMainMenu(CSVProcessor WineFile, List<WineItem> wineList)
        {
            bool quitMainBoolean = false;

            // do while loop keeps showing the menu
            do
            {
                Console.WriteLine("Select an option: \n \n 1. Load the csv file of wine list.  2. Exit program.");
                string optionSelection = Console.ReadLine();

                if (optionSelection == "1")
                {
                    quitMainBoolean = true;
                    WineFile.ReadCSV(wineList);
                }
                else if (optionSelection == "2")
                {
                    Environment.Exit(0);
                }

            } while (quitMainBoolean != true);
        }
        public void Collection() // Option 1
        {
            // Call WineItems class
            WineItem[] wineItems = new WineItem[3964];

            // Call CSVProcessor class
            CSVProcessor wineList = new CSVProcessor();

            // Load CSV file into an array with the fields from WineItem class
            wineList.AccessCSVFile("../data/WineList.csv", wineItems);

            int index = 0;

            // Foreach loop fills collection array
            foreach (WineItem item in wineItems)
            {
                if (item != null)
                {
                    collection[index] = item.ToString();
                }
                index++;
            }
        }
        public void Collection() // Option 1
        {
            // Call WineItems class
            WineItem[] wineItems = new WineItem[3964];

            // Call CSVProcessor class
            CSVProcessor wineList = new CSVProcessor();

            // Load CSV file into an array with the fields from WineItem class
            wineList.AccessCSVFile("../data/WineList.csv", wineItems);

            int index = 0;

            // Foreach loop fills collection array
            foreach (WineItem item in wineItems)
            {
                if (item != null)
                {
                    collection[index] = item.ToString();
                }
                index++;
            }
        }
        public void ProcessCSV()                                 //Used to allow the CSVProcessor class to use the array
        {
            CSVProcessor csvProcessor = new CSVProcessor();

            csvProcessor.ProcessCSV("../../../datafiles/WineList.csv", wineItemList);            //Incorrect path, I'm not sure what the correct one is
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            bool isLoadedCSV = false;
            UserInterface ui = new UserInterface();
            WineItem wineItem = new WineItem();
            WineItemCollections wineItemCollection = new WineItemCollections();
            CSVProcessor file = new CSVProcessor();


            int choice = ui.GetUserInput();

            while (choice != 5) // exits program if user selects 5, otherwise menu keeps displaying
            {
                switch (choice)
                {
                    case 1:
                        {
                            if (!isLoadedCSV) // loads file first time, afterward displays that it's already been loaded
                            {
                                file.ImportCSV("../../../datafiles/WineList.csv", wineItemCollection);
                                Console.WriteLine("File successfully loaded.");
                                Console.WriteLine();
                                isLoadedCSV = true;
                            }
                            else
                            {
                                Console.WriteLine("File has already been loaded.");
                                Console.WriteLine();
                            }
                            break;
                        }
                    case 2:
                        {
                            // displays all wine items
                            Console.WriteLine(wineItemCollection.ToString());
                            Console.WriteLine();
                            break;
                        }

                    case 3:
                        {
                            // allows user to search for wine by ID and displays wine info or that wine does not exist
                            Console.WriteLine("Enter the ID you wish to search for: ");
                            string searchWineItemID = Console.ReadLine();
                            WineItem wineItemResult = wineItemCollection.SearchWine(searchWineItemID);
                            if (wineItemResult != null)
                            {
                                Console.WriteLine(wineItemResult.ToString());
                            }
                            else
                            {
                                Console.WriteLine("The ID was not found in the database.");
                            }
                            Console.WriteLine();
                            break;
                        }

                    case 4:
                        {
                            // allows user to add wine item to array if the ID is not already in the database


                            Console.WriteLine("Please enter the wine ID: ");
                            string userID = Console.ReadLine();
                            WineItem wineItemResult = wineItemCollection.SearchWine(userID);
                            if (wineItemResult != null) 
                            {
                                Console.WriteLine("That ID is already in the database.");
                            }
                            else
                            {
                                Console.WriteLine("Please enter the wine description: ");
                                string userDescription = Console.ReadLine();

                                Console.WriteLine("Please enter the wine pack: ");
                                string userPack = Console.ReadLine();

                                WineItem userWineItem = new WineItem(userID, userDescription, userPack);
                                wineItemCollection.AddWineItem(userWineItem);

                                Console.WriteLine();
                                Console.WriteLine(userWineItem.ToString() + " successfully added.");
                                Console.WriteLine();
                            }

                            
                        }

                        break;
                }

                choice = ui.GetUserInput();
            }

            
        }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            Console.WriteLine("Must load csv file first to print");
            Console.WriteLine("type load to Load the list");
            Console.WriteLine("Type list to print list");
            Console.WriteLine("type seach to search list");
            Console.WriteLine("type add to add wine ");
            Console.WriteLine("Exit");

            Console.Write("Choose an option: ");
            UserInputMenu = Console.ReadLine(); //user input

            //objects from diffent classes
            WineItemCollection wineCollection = new WineItemCollection();
            CSVProcessor listWine = new CSVProcessor();
            WineItemCollection wineAdd = new WineItemCollection();
            WineItemCollection searchWine = new WineItemCollection();

            //whlie loops that keep going until users hit exit
             while (UserInputMenu != "exit")
             {
             //loads csv file
               if (UserInputMenu == "load")

              {
              //loadWine();
              listWine.load(wineCollection);
              loadMenu();
              }
               //print csv file
              else if (UserInputMenu == "list")
            {
              //  printWine();

                Console.Write("You typed in list");

                   Console.WriteLine(wineCollection.getWineCollection());
                   loadMenu();

            }
               //seach csv file
            else if (UserInputMenu == "search")
            {

                string wineIdInput = string.Empty;

                Console.Write("You typed in search");
                Console.WriteLine("Enter wine id");
                wineIdInput = Console.ReadLine();
                Console.WriteLine( searchWine.searchId(wineIdInput));
                loadMenu();
            }
               //add to the csv file
            else if (UserInputMenu == "add")
            {
                Console.WriteLine("You typed in add");
                wineAdd.WineAdd();
                loadMenu();
            }

            else if (UserInputMenu == "exit")
            {
                End();
            }
            else //if(UserInputMenu != "eixt" || UserInputMenu != "list" || UserInputMenu != "load" || UserInputMenu != "search")
            {
                Console.WriteLine(UserInputMenu +" is not an option");
                Console.WriteLine("please enter one the following");
                loadMenu();
            }
             }
        }
Exemplo n.º 20
0
 public void PrintFullList()
 {
     CSVProcessor csvProcessor = new CSVProcessor();
     for (int i = 0; i < 4000; i++)
         Console.WriteLine(csvProcessor.fullListArray[i]);
 }
 public wineItemCollection(CSVProcessor refrence)
     : this(refrence.WineArray)
 {
 }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            // Launch introUI
            UserInterface introUI = new UserInterface();
            int uiChoice = introUI.IntroInput();
            // While choice isn't EXIT
            while (uiChoice != 2)
            {
                // Load new instance of the CSV Processor
                CSVProcessor csvProcessor = new CSVProcessor();
                // !!! SET THIS FILE PATH MANUALLY !!!
                csvProcessor.ImportCSV(@"..\datafiles\WineList.csv");
                // load wineItems locally
                List<WineItem> wineItems = csvProcessor.GetWineItems();
                // While user makes any choice in the main UI
                while (uiChoice == 1 || uiChoice == 2 || uiChoice == 3)
                {
                    // New instance of the main UI
                    UserInterface mainUI = new UserInterface();
                    uiChoice = mainUI.MainInput();
                    // Set up the case statement for the main UI
                    int uiSwitch = uiChoice;
                    switch (uiSwitch)
                    {
                        case 1:
                            // Print out the entire list of items with a for loop
                            for (int i = 0; i <= wineItems.Count - 1; i++)
                            {
                                Console.WriteLine(wineItems[i].ToString());
                            }
                            break;
                        case 2:
                            // Allow user to search for items in the List
                                Console.WriteLine("ENTER ITEM ID TO SEARCH FOR:");
                                string userInput = Console.ReadLine();
                                bool flag = false;
                            // for loop to search for entered text in the entire list
                                for(int i = 0; i <= wineItems.Count - 1; i++)
                                {
                                    if (wineItems[i].ItemID.Equals(userInput) && wineItems[i] != null)
                                    {
                                        Console.WriteLine("MATCHING ITEM ID FOUND:" + Environment.NewLine +
                                            wineItems[i].ToString());
                                        flag = true;
                                    }
                                }
                            // show no results
                                if (flag == false)
                                {
                                    Console.WriteLine("NO MATCHING ITEM ID");
                                }
                                break;
                        case 3:
                            // Allow user to enter an item
                                string enteredID, enteredDescription, enteredPack;
                                Console.WriteLine("ENTER NEW ID:");
                                enteredID = Console.ReadLine();
                                Console.WriteLine("ENTER NEW DESCRIPTION");
                                enteredDescription = Console.ReadLine();
                                Console.WriteLine("ENTER NEW PACK");
                                enteredPack = Console.ReadLine();
                            // Add item to WineItem list
                                wineItems.Add(new WineItem(enteredID, enteredDescription, enteredPack));
                                Console.WriteLine(wineItems[wineItems.Count -1].ToString());
                                break;
                        default:
                                break;
                    }

                }
                uiChoice = introUI.IntroInput();
            }
        }
Exemplo n.º 23
0
        //Establishes a StreamReader, Random Number, UserInterface.
        //Establishes the WineItem & WineItemCollection class arrays bases on the size of the input file.
        //Reads the input file into the WineItem array.
        //Directs the program based on user input.
        static void Main(string[] args)
        {
            StreamReader  wineList     = new StreamReader("../../../datafiles/WineList.csv");
            Random        randomNumber = new Random();
            UserInterface ui           = new UserInterface();

            Int32 arrayCount      = CSVProcessor.Processor(wineList);
            Int32 addToArrayCount = arrayCount;

            WineItem[]           wineItems   = new WineItem[arrayCount + 5];
            WineItemCollection[] collections = new WineItemCollection[arrayCount + 5];
            CSVProcessor.ReadFile(wineItems, wineList);

            Int32 selection1_Int32 = 0;

            //While the user has not chosen to exit the program.
            while (selection1_Int32 != 5)
            {
                selection1_Int32 = ui.InputMenu1();
                String output;

                switch (selection1_Int32)
                {
                //Displays the output as found in the input file.
                //This will display the array in a sorted order if it has already been sorted (if choice 2 or 3 has already been selected).
                case 1:
                {
                    output = WineItem.CreateString(wineItems);
                    ui.PrintAllOutput(output);
                    break;
                }

                //Displays the output in ascending or descending order with item location.
                case 2:
                {
                    Int32 selection2_Int32 = 0;
                    selection2_Int32 = ui.InputMenu2();
                    WineItemCollection.SetLocation(wineItems, collections, randomNumber);
                    output = WineItem.CreateLongString(wineItems, collections, selection2_Int32);
                    ui.PrintAllOutput(output);
                    selection2_Int32 = 0;
                    break;
                }

                //Prompts the user for input and searches the file for matching items.
                //Prompts the user for a search method as well.
                //Dispays a message for successful and unsuccessful searches.
                case 3:
                {
                    Int32  foundLocation    = -1;
                    String temp             = ui.SearchId();
                    Int32  selection3_Int32 = ui.InputMenu3();
                    foundLocation = WineItem.SearchType(wineItems, temp, selection3_Int32, arrayCount);
                    if (foundLocation == -1)
                    {
                        ui.NotFound(temp);
                    }
                    break;
                }

                //Allows the user to add items to the wine directory (up to 5 items).
                case 4:
                {
                    addToArrayCount = ui.UserAddWine(wineItems, addToArrayCount);
                    //addToArrayCount++;
                    break;
                }

                //Exit loop selection
                case 5:
                {
                    //Do Nothing - proceed to close the program.
                    break;
                }
                }
            }
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            //Set a constant for the size of the collection
            const int wineItemCollectionSize = 4000;

            //Set a constant for the path to the CSV File
            const string pathToCSVFile = "../../../datafiles/winelist.csv";

            //Create an instance of the UserInterface class
            UserInterface userInterface = new UserInterface();

            //Create an instance of the WineItemCollection class
            IWineCollection wineItemCollection = new WineItemCollection(wineItemCollectionSize);

            //Create an instance of the CSVProcessor class
            CSVProcessor csvProcessor = new CSVProcessor();

            //Display the Welcome Message to the user
            userInterface.DisplayWelcomeGreeting();

            //Display the Menu and get the response. Store the response in the choice integer
            //This is the 'primer' run of displaying and getting.
            int choice = userInterface.DisplayMenuAndGetResponse();

            while (choice != 5)
            {
                switch (choice)
                {
                    case 1:
                        //Load the CSV File
                        bool success = csvProcessor.ImportCSV(wineItemCollection, pathToCSVFile);
                        if (success)
                        {
                            //Display Success Message
                            userInterface.DisplayImportSuccess();
                        }
                        else
                        {
                            //Display Fail Message
                            userInterface.DisplayImportError();
                        }
                        break;

                    case 2:
                        //Print Entire List Of Items
                        string[] allItems = wineItemCollection.GetPrintStringsForAllItems();
                        if (allItems.Length > 0)
                        {
                            //Display all of the items
                            userInterface.DisplayAllItems(allItems);
                        }
                        else
                        {
                            //Display error message for all items
                            userInterface.DisplayAllItemsError();
                        }
                        break;

                    case 3:
                        //Search For An Item
                        string searchQuery = userInterface.GetSearchQuery();
                        string itemInformation = wineItemCollection.FindById(searchQuery);
                        if (itemInformation != null)
                        {
                            userInterface.DisplayItemFound(itemInformation);
                        }
                        else
                        {
                            userInterface.DisplayItemFoundError();
                        }
                        break;

                    case 4:
                        //Add A New Item To The List
                        string[] newItemInformation = userInterface.GetNewItemInformation();
                        if (wineItemCollection.FindById(newItemInformation[0]) == null)
                        {
                            wineItemCollection.AddNewItem(newItemInformation[0], newItemInformation[1], newItemInformation[2]);
                            userInterface.DisplayAddWineItemSuccess();
                        }
                        else
                        {
                            userInterface.DisplayItemAlreadyExistsError();
                        }
                        break;
                }

                //Get the new choice of what to do from the user
                choice = userInterface.DisplayMenuAndGetResponse();
            }
        }
Exemplo n.º 25
0
 public controlClass(wineItemCollection collection, CSVProcessor processor)
 {
     processCSV = processor;
     collectedWineItems = collection;
 }
 public void ProcessCSV()                                 //Used to allow the CSVProcessor class to use the array
 {
     CSVProcessor csvProcessor = new CSVProcessor();
     csvProcessor.ProcessCSV("../../../datafiles/WineList.csv", wineItemList);            //Incorrect path, I'm not sure what the correct one is
 }
Exemplo n.º 27
0
        static void Main(string[] args)
        {
            //Set a constant for the size of the collection
            const int wineItemCollectionSize = 4000;

            //Set a constant for the path to the CSV File
            const string pathToCSVFile = "../../../datafiles/winelist.csv";

            //Create an instance of the UserInterface class
            UserInterface userInterface = new UserInterface();

            //Create an instance of the WineItemCollection class
            WineItemCollection wineItemCollection = new WineItemCollection(wineItemCollectionSize);

            //Create an instance of the CSVProcessor class
            CSVProcessor csvProcessor = new CSVProcessor();

            //Display the Welcome Message to the user
            userInterface.DisplayWelcomeGreeting();

            //Display the Menu and get the response. Store the response in the choice integer
            //This is the 'primer' run of displaying and getting.
            int choice = userInterface.DisplayMenuAndGetResponse();

            while (choice != 5)
            {
                switch (choice)
                {
                case 1:
                    //Load the CSV File
                    bool success = csvProcessor.ImportCSV(wineItemCollection, pathToCSVFile);
                    if (success)
                    {
                        //Display Success Message
                        userInterface.DisplayImportSuccess();
                    }
                    else
                    {
                        //Display Fail Message
                        userInterface.DisplayImportError();
                    }
                    break;

                case 2:
                    //Print Entire List Of Items
                    string[] allItems = wineItemCollection.GetPrintStringsForAllItems();
                    if (allItems.Length > 0)
                    {
                        //Display all of the items
                        userInterface.DisplayAllItems(allItems);
                    }
                    else
                    {
                        //Display error message for all items
                        userInterface.DisplayAllItemsError();
                    }
                    break;

                case 3:
                    //Search For An Item
                    string searchQuery     = userInterface.GetSearchQuery();
                    string itemInformation = wineItemCollection.FindById(searchQuery);
                    if (itemInformation != null)
                    {
                        userInterface.DisplayItemFound(itemInformation);
                    }
                    else
                    {
                        userInterface.DisplayItemFoundError();
                    }
                    break;

                case 4:
                    //Add A New Item To The List
                    string[] newItemInformation = userInterface.GetNewItemInformation();
                    if (wineItemCollection.FindById(newItemInformation[0]) == null)
                    {
                        wineItemCollection.AddNewItem(newItemInformation[0], newItemInformation[1], newItemInformation[2]);
                        userInterface.DisplayAddWineItemSuccess();
                    }
                    else
                    {
                        userInterface.DisplayItemAlreadyExistsError();
                    }
                    break;
                }

                //Get the new choice of what to do from the user
                choice = userInterface.DisplayMenuAndGetResponse();
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// For debugging/testing purposes. Bypasses UserInterface class and tests individual classes directly.
        /// </summary>
        private void Testing()
        {
            #region WineItemTest

            Console.WriteLine(Environment.NewLine + "******************************" + Environment.NewLine +
                "Test For WineItem functionality." + Environment.NewLine +
                "******************************" + Environment.NewLine);

            string ID1 = "12345";
            string ID2 = "67890";
            string aDesc1 = "aDesc";
            string aDesc2 = "OtherDesc";
            string aSize1 = "Size 1";
            string aSize2 = "Size 500";

            WineItem WineTest1 = new WineItem(ID1, aDesc1, aSize1);
            WineItem WineTest2 = new WineItem(ID2, aDesc2, aSize2);

            Console.WriteLine("TEST- ForcePrint:" + Environment.NewLine +
                WineTest1.WineID + " " + WineTest1.WineDescription + " " + WineTest1.WineSize + Environment.NewLine);

            Console.WriteLine("TEST- ToString():");
            Console.WriteLine(WineTest1.ToString());
            Console.WriteLine(WineTest2.ToString());

            Console.WriteLine(Environment.NewLine);

            #endregion

            #region WineItemCollectionTest

            Console.WriteLine(Environment.NewLine + "******************************" + Environment.NewLine +
                "Test For Collection functionality." + Environment.NewLine +
                "******************************" + Environment.NewLine);

            WineItemCollection collectionTest = new WineItemCollection(5);
            collectionTest.LoadWineItem(WineTest1, 0, 1);
            collectionTest.LoadWineItem(WineTest2, 1, 1);

            Console.WriteLine("TEST- Above items added to collection and displayed:");
            Console.WriteLine(collectionTest.GetCollectionToString());

            #endregion

            #region CSVProcessorTest

            Console.WriteLine(Environment.NewLine + "******************************"
             + Environment.NewLine + "Test For CSVProcessor functionality." + Environment.NewLine +
             "******************************" + Environment.NewLine);

            CSVProcessor loadThings = new CSVProcessor();

            int ArraySize = loadThings.LoadListSize;
            Console.WriteLine("TEST- # of Items loaded: " + Environment.NewLine + ArraySize + Environment.NewLine);

            WineItemCollection wineCollection = new WineItemCollection(ArraySize);
            loadThings = new CSVProcessor(wineCollection, 0);

            Console.WriteLine("TEST- Collection Contents After Load:");
            Console.WriteLine(wineCollection.GetCollectionToString());

            #endregion
        }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            int choiceInt = 1;
            string idString;

            UserInterface ui = new UserInterface();
            CSVProcessor csvp = new CSVProcessor();
            WineItemCollection WIC = new WineItemCollection();

            while (choiceInt != 0)
            {
                bool error = false;
                ui.DisplayMenu();
                try
                {
                    choiceInt = Convert.ToInt32(ui.ReadLine());

                }
                catch
                {
                    ui.InvalidEntry();
                    error = true;
                }

                if (!error)
                {
                    switch (choiceInt)
                    {
                        case 0:

                            break;
                        case 1: //Load the file
                            if (csvp.Loaded)
                                ui.FilesAlreadyLoaded();
                            else
                            {
                                csvp.LoadFiles();
                                ui.FilesLoaded();
                            }
                            break;

                        case 2: //Display all files
                            if (csvp.Loaded)
                                ui.DisplayFiles();
                            else
                                ui.FilesNotLoaded();
                            break;

                        case 3: //Find item by id
                            if (csvp.Loaded)
                            {
                                ui.ItemSearchMessage();
                                idString = ui.ReadLine();
                                ui.ItemSearchResult(WIC.FindItem(idString));
                            }
                            else
                                ui.FilesNotLoaded();
                            break;

                        case 4: //Add item
                            if (csvp.Loaded)
                            {
                                WineItem temp = new WineItem(ui.NewItemId(), ui.NewItemDescription(), ui.NewItemPack());

                                ui.DisplayText(WIC.AddItem(temp));

                            }
                            else
                                ui.FilesNotLoaded();
                            break;

                        default:
                            ui.AnotherNumber();
                            break;
                    }
                }
            }
        }
Exemplo n.º 30
0
 /// <summary>
 /// Handles Menu option 1. Loading from Wine List.
 /// </summary>
 private void LoadWineList()
 {
     // While has not been loaded yet.
     if (collectionLoadedBool == false)
     {
         indexInt = wineItemCollection.CurrentIndex;
         // If no items are present in the collection.
         if (wineItemCollection.WineItemArray[0] == null)
         {
             processFiles = new CSVProcessor(wineItemCollection, indexInt);
         }
         else
         {
             while (wineItemCollection.WineItemArray[indexInt] != null)
             {
                 indexInt++;
             }
             processFiles = new CSVProcessor(wineItemCollection, indexInt);
         }
         collectionLoadedBool = true;
     }
     else
     {
         mainMenu.DisplayLine("Wine list has already been loaded.");
     }
 }