public List<ProductType> GetProductTypes()
        {
            List<ProductType> products = new List<ProductType>();

            string[] data = File.ReadAllLines(@"Data\Products.txt");
            for (int i = 1; i < data.Length; i++)
            {
                string[] row = data[i].Split(',');

                ProductType toAdd = new ProductType();
                toAdd.Type = row[0];
                toAdd.CostPerSquareFoot = decimal.Parse(row[1]);
                toAdd.LaborCostPerSquareFoot = decimal.Parse(row[2]);

                products.Add(toAdd);
            }

            return products;
        }
示例#2
0
        //methods to prompt for certain input *****************************************************
        private static decimal PromptForValidArea(ProductType currentProductType, bool extraInfo = false)
        {
            decimal area = 0M;
            bool error = false;
            bool validArea = false;
            while (!validArea)
            {
                if (!extraInfo || error)
                {
                    OffsetTop();
                }

                if (error)
                {
                    Console.ForegroundColor = ErrorColor;
                    Console.WriteLine("\tInvalid entry.");
                    Console.ResetColor();
                    Console.WriteLine();
                }
                Console.ForegroundColor = PromptColor;
                Console.Write("\tEnter the area of {0} (in sq ft): ", currentProductType.Type.ToLower());
                Console.ForegroundColor = EmphasisColor;
                string userInput = Console.ReadLine().Trim();
                Console.Clear();
                Console.ResetColor();

                if (decimal.TryParse(userInput, out area) && area >= 0M)
                {
                    validArea = true;
                }
                else
                {
                    Console.Clear();
                    error = true;
                }
            }

            return area;
        }