示例#1
0
        static void Main(string[] args)
        {
            VisionExpress  visionexpress2  = new VisionExpress();
            GlassesBuilder glassesbuilder2 = new MultifocalBuilder();

            visionexpress2.ConstructGlasses(glassesbuilder2);
            glassesbuilder2.Glasses.Display();
            Console.WriteLine(); //pusty wiersz
            GlassProduct testglass = new GlassProduct();
            var          testuv    = new Filters(FiltersEnum.UV);

            testglass.AddElement(testuv);
            var testDefect = new DefectValue(10, -10);

            testglass.AddElement(testDefect);
            var testrims = new Rims(RimTypesEnum.Gucci);

            glassesbuilder2.Glasses.Rims      = testrims.Name;
            glassesbuilder2.Glasses.RimsPrice = testrims.Price;
            glassesbuilder2.Glasses.Price    += testuv.Price;
            glassesbuilder2.Glasses.Price    += testDefect.Price;

            //dupa.ShowList();
            testglass.AddToGlasses(glassesbuilder2.Glasses);
            glassesbuilder2.Glasses.Display();
            string path = @"Test.txt";

            if (!File.Exists(path))
            {
                // Create a file to write to.
                using (StreamWriter sw = File.CreateText(path))
                {
                    sw.WriteLine("Orders:");
                    sw.WriteLine("-------------");
                }
            }
            using (StreamWriter sw = File.AppendText(path))
            {
                sw.WriteLine("typ:" + glassesbuilder2.Glasses._type);
                sw.WriteLine("lenses:" + glassesbuilder2.Glasses.Lenses);
                sw.WriteLine("lenses price:" + glassesbuilder2.Glasses.LensesPrice);
                sw.WriteLine("Rims:" + glassesbuilder2.Glasses.Rims);
                sw.WriteLine("Rims price:" + glassesbuilder2.Glasses.RimsPrice);
                foreach (IComposite el in glassesbuilder2.Glasses.AdditionList)
                {
                    sw.WriteLine(el.Name + " " + el.Price);
                }
                sw.WriteLine("Total price:" + (glassesbuilder2.Glasses.LensesPrice + glassesbuilder2.Glasses.RimsPrice + glassesbuilder2.Glasses.Price));
                sw.WriteLine("-------------");
            }
        }
示例#2
0
        void SaveOrderBtn(object sender, RoutedEventArgs e)
        {
            double baseCLPrice = 0;

            if (contactLenses != null)
            {
                baseCLPrice = contactLenses.Price;
            }
            if (glasses != null)
            {
                glassAdditions.AddToGlasses(glasses);
                foreach (IComposite el in glasses.AdditionList)
                {
                    glasses.Price += el.Price;
                }
            }
            else
            {
                glassAdditions.AddToContactLenses(contactLenses);
                foreach (IComposite el in contactLenses.AdditionList)
                {
                    contactLenses.Price += el.Price / 100;
                }
            }
            string path = @"Test.txt";

            if (!File.Exists(path))
            {
                using (StreamWriter sw = File.CreateText(path))
                {
                    sw.WriteLine("Orders:");
                    sw.WriteLine("-------------");
                }
            }
            using (StreamWriter sw = File.AppendText(path))
            {
                if (glasses != null)
                {
                    sw.WriteLine("Glasses");
                    sw.WriteLine("type: " + glasses._type);
                    sw.WriteLine("lenses type: " + glasses.Lenses);
                    sw.WriteLine($"lenses price: {glasses.LensesPrice:c}");
                    sw.WriteLine("Rims: " + glasses.Rims);
                    sw.WriteLine($"Rims price: {glasses.RimsPrice:c}");
                    foreach (IComposite el in glasses.AdditionList)
                    {
                        sw.WriteLine($"{el.Name}, price: {el.Price:c}");
                    }
                    sw.WriteLine($"Total price: {glasses.Price:c}");
                    sw.WriteLine("-------------");
                }
                else
                {
                    sw.WriteLine("Contact lenses");
                    sw.WriteLine("type: " + contactLenses._type);
                    sw.WriteLine($"base price: {baseCLPrice:c}");
                    sw.WriteLine("color: " + contactLenses.cLColor);
                    if (contactLenses.cLColor.ToString() != "Standard")
                    {
                        sw.WriteLine($"color price: {contactLenses.colorPrice:c}");
                    }
                    foreach (IComposite el in contactLenses.AdditionList)
                    {
                        sw.WriteLine($"{el.Name}, price: {(el.Price / 100):c}");
                    }
                    sw.WriteLine($"Total price: {contactLenses.Price + contactLenses.colorPrice:c}");
                    sw.WriteLine("-------------");
                }
            }
            ResetCurrentValues();
        }