Ejemplo n.º 1
0
        public void TestMethod3()
        {
            decimal expectedTotalPrice = decimal.Round((decimal)74.68, 2, MidpointRounding.AwayFromZero);
            decimal expectedTotalTaxes = decimal.Round((decimal)6.70, 2, MidpointRounding.AwayFromZero);

            Console.WriteLine("Input3:");
            Cosmetic c1 = new Cosmetic("bottle of perfume", 1, (decimal)27.99, true);
            Cosmetic c2 = new Cosmetic("bottle of perfume", 1, (decimal)18.99, false);
            Drug     d  = new Drug("packet of headache pills", 1, (decimal)9.75, false);
            Food     f  = new Food("box of chocolates", 1, (decimal)11.25, true);

            Console.WriteLine(c1.ToStringWithoutTaxes());
            Console.WriteLine(c2.ToStringWithoutTaxes());
            Console.WriteLine(d.ToStringWithoutTaxes());
            Console.WriteLine(f.ToStringWithoutTaxes());
            Console.WriteLine("Output1:");
            Console.WriteLine(c1.ToString());
            Console.WriteLine(c2.ToString());
            Console.WriteLine(d.ToString());
            Console.WriteLine(f.ToString());
            decimal totalTaxes = c1.GetTotalTaxes() + c2.GetTotalTaxes() + d.GetTotalTaxes() + f.GetTotalTaxes();
            decimal totalPrice = c1.GetTotalPrice() + c2.GetTotalPrice() + d.GetTotalPrice() + f.GetTotalPrice();

            Console.WriteLine("Sales Taxes: " + totalTaxes);
            Console.WriteLine("Total: " + totalPrice);
            Assert.AreEqual(totalTaxes, expectedTotalTaxes);
            Assert.AreEqual(totalPrice, expectedTotalPrice);
        }
Ejemplo n.º 2
0
        public async Task <RuntimeResult> GetHighAsync(Drug TheDrug)
        {
            switch (TheDrug)
            {
            case Drug.Fafafa:
            case Drug.Falopa:
            case Drug.FasoRico:
            case Drug.LSD:
            case Drug.Merluza: return(FalopaRuntimeResult.FromSuccess($"¿Tenés {TheDrug.ToString()}? ¡Al toque, Roque!"));

            default: return(FalopaRuntimeResult.FromError("Nah, paso."));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates an object that contains a list with all planned takings for a drug, based on the start- and endtime and the day times where the drug needs to be taken
        /// author: Florian Schnyder
        /// </summary>
        /// <param name="drug">Contanis the drug object for which the taking plan has been created</param>
        /// <param name="takingStart">Startpoint for drug reminder</param>
        /// <param name="takingEnd">Endpoint for a drug reminder, if the enddate is alredy known</param>
        /// <param name="takingDayTime">Contanis the information at which points of the day (morning, lunch, evening, night) the drug should be taken</param>
        /// <param name="takingTime">Contanis the information at what time i have to take the drug</param>
        public TakingPlan(Drug drug, DateTime takingStart, DateTime takingEnd, DayTime takingDayTime, Dictionary<DayTime, DateTime> takingTime)
        {
            this.drug = drug;
            this.takingStart = takingStart;
            this.takingEnd = takingEnd;
            this.takingDayTime = takingDayTime;
            this.takingTime = takingTime;

            //create an XML file with the implemented method
            XmlDocument file = createXML();
            DateTime time = DateTime.Now.AddMinutes(1);

            //add the notificaction to the operating system
            ScheduledToastNotification noti = new ScheduledToastNotification(file, time);
            noti.Id = drug.ToString();
            ToastNotificationManager.CreateToastNotifier().AddToSchedule(noti); 

            //creates daily notifications for the drug if the flag in DayTime is set. At the moment only for one week and without checking the takingEndDate....
            if (drug != null && this.takingStart != null && this.takingStart >= DateTime.Now)
            {
                Settings settings = Settings.Instance;

                //checks if the flag at the specified position is set. If yes, the durg will be added to the realted list
                if (takingDayTime.HasFlag(DayTime.Morning))
                {
                    //create an XML file with the implemented method
                    XmlDocument xml = createXML();

                    //add temporary variable to count one week
                    int temp = 0;

                    //Get the current year, month and day, afterwards, get the needed data form the settings class (just for prototype, afterwards, it will check the drugs own daily taking times)
                    DateTime plannedTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, settings.DefaultMorningTakingTime.Hours, settings.DefaultMorningTakingTime.Minutes, 0);

                    while (temp < 7)
                    {
                        plannedTime = plannedTime.AddDays(1);
                        // add the notification to the operating system
                        ScheduledToastNotification toast = new ScheduledToastNotification(xml, plannedTime);
                        toast.Id = drug.ToString() + temp;
                        ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
                        temp++;
                    }

                }

                if (takingDayTime.HasFlag(DayTime.Lunch))
                {
                    //create an XML file with the implemented method
                    XmlDocument xml = createXML();

                    //add temporary variable to count one week
                    int temp = 0;

                    //Get the current year, month and day, afterwards, get the needed data form the settings class (just for prototype, afterwards, it will check the drugs own daily taking times)
                    DateTime plannedTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, settings.DefaultLunchTakingTime.Hours, settings.DefaultLunchTakingTime.Minutes, 0);

                    while (temp < 7)
                    {
                        plannedTime = plannedTime.AddDays(1);
                        // add the notification to the operating system
                        ScheduledToastNotification toast = new ScheduledToastNotification(xml, plannedTime);
                        toast.Id = drug.ToString() + temp;
                        ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
                        temp++;
                    }

                }

                if (takingDayTime.HasFlag(DayTime.Evening))
                {
                    //create an XML file with the implemented method
                    XmlDocument xml = createXML();

                    //add temporary variable to count one week
                    int temp = 0;

                    //Get the current year, month and day, afterwards, get the needed data form the settings class (just for prototype, afterwards, it will check the drugs own daily taking times)
                    DateTime plannedTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, settings.DefaultEveningTakingTime.Hours, settings.DefaultEveningTakingTime.Minutes, 0);

                    while (temp < 7)
                    {
                        plannedTime = plannedTime.AddDays(1);
                        // add the notification to the operating system
                        ScheduledToastNotification toast = new ScheduledToastNotification(xml, plannedTime);
                        toast.Id = drug.ToString() + temp;
                        ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
                        temp++;
                    }

                }

                if (takingDayTime.HasFlag(DayTime.Night))
                {
                   
                    XmlDocument xml = createXML();

                    //add temporary variable to count one week
                    int temp = 0;

                    //Get the current year, month and day, afterwards, get the needed data form the settings class (just for prototype, afterwards, it will check the drugs own daily taking times)
                    DateTime plannedTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, settings.DefaultNightTakingTime.Hours, settings.DefaultNightTakingTime.Minutes, 0);

                    while (temp < 7)
                    {
                        plannedTime = plannedTime.AddDays(1);
                        // add the notification to the operating system
                        ScheduledToastNotification toast = new ScheduledToastNotification(xml, plannedTime);
                        toast.Id = drug.ToString() + temp;
                        ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
                        temp++;
                    }
                }
            }
        }
 static string ShortString(Drug data)
 {
     return(data.ToString());
 }