Ejemplo n.º 1
0
        public static double MaxDrop(List<saveData> ListSaveData)
        {
            if (ListSaveData.Count() >= 3)
            {
                double prev = ListSaveData[0].getTotalSum();
                double now = ListSaveData[0].getTotalSum();
                double next = ListSaveData[0].getTotalSum();
                int count = 0;
                bool b = false;
                double Max = 0, MaxDrop = 0;
                foreach (saveData o in ListSaveData)
                {
                    if (count < 3)
                        count++;
                    else
                    {
                        if (!b)
                        {
                            if (now > prev && now < next)
                            {
                                Max = now;
                                b = true;
                            }
                            else
                            {
                                prev = now;
                                now = next;
                                next = o.getProfit();
                            }
                        }
                        else
                        {
                            if (now < prev && now > next)
                            {
                                if (MaxDrop < (Max - now))
                                    MaxDrop = Max - now;
                                b = false;
                            }
                            else
                            {
                                prev = now;
                                now = next;
                                next = o.getProfit();
                            }

                        }
                    }
                }
                return MaxDrop;
            }
            else
            {
                if (ListSaveData.Count() == 1 /*|| ListSaveData.Count() == 0*/)
                    return 0.0;
                else
                {
                    return Math.Abs(ListSaveData[0].getTotalSum() - ListSaveData[1].getTotalSum());
                }
            }//foreach End
         }
Ejemplo n.º 2
0
 public static double[] pointGenerator(List<double> lis)
 {
     Point[] p = new Point[lis.Count()];
     for (int i = 0; i < p.Length; i++)
     {
         p[i] = new Point(i, lis[i]);    
         
     }
     return linerAndA(p);
 }
Ejemplo n.º 3
0
 private string SwapPrevious(List<int> orderList, int id)
 {
     int temp = -1;
     string newProjectOrder = "";
     try
     {
         for (int i = 1; i < orderList.Count(); i++)
         {
             if (orderList[i] == id)
             {
                 temp = orderList[i - 1];
                 orderList[i - 1] = orderList[i];
                 orderList[i] = temp;
             }
         }
     }
     catch (Exception e)
     {
         return null;
     }
     foreach (int y in orderList)
     {
         newProjectOrder += y + " ";
     }
     newProjectOrder = newProjectOrder.TrimEnd().Replace(' ', ',');
     return newProjectOrder;
 }