Exemple #1
0
        static void Main(string[] args)
        {
            //new objects
            var car1 = new CAR("1", true);
            var car2 = new CAR("2");
            var car3 = new CAR("3");
            var car4 = new CAR("4", false, true);
            var car5 = new CAR("5", false, true);
            var car6 = new CAR("6");
            var car7 = new CAR("7");

            //build relations among them
            car1.AddNextCAR(car2);
            car2.AddNextCAR(car3);
            car2.AddNextCAR(car4);
            car2.AddNextCAR(car5);
            car3.AddNextCAR(car6);
            car6.AddNextCAR(car5);
            car4.AddNextCAR(car7);

            //get l_case
            CASE_Builder cb = new CASE_Builder(car1);

            cb.ReBuild();
            var l_case = cb.LCASE;

            //show l_case
            foreach (var c in l_case)
            {
                Console.WriteLine(c.ToPathString());
            }

            //Wait
            Console.ReadKey();
        }
Exemple #2
0
        private static List <CASE> GetResults(CAR car1)
        {
            List <CASE> l_case = new List <CASE>();
            var         xcase  = new CASE();

            xcase.Add(car1);
            l_case.Add(xcase);

            if (car1.NextCARs != null)
            {
                if (true) //cover all
                {
                    foreach (var car in car1.NextCARs)
                    {
                        if (!xcase.Exists(car))
                        {
                            xcase.Add(car);
                        }
                        else
                        {
                            xcase = new CASE();
                            l_case.Add(xcase);
                            xcase.Add(car1);
                            xcase.Add(car);
                        }
                    }
                }
            }
            return(l_case);
        }
Exemple #3
0
 public void Add(CAR car)
 {
     this.CARS.Add(car);
     if (car.IsEnd)
     {
         this.IsEnd = true;
     }
 }
Exemple #4
0
 public void AddNextCAR(CAR car)
 {
     this.NextCARs.Add(car);
 }
Exemple #5
0
 public CASE_Builder(CAR startCAR)
 {
     this.StartCAR = startCAR;
 }
Exemple #6
0
 public bool EndWith(CAR car)
 {
     return(this.EndCAR == car);
 }
Exemple #7
0
 public bool StartWith(CAR car)
 {
     return(this.StartCAR == car);
 }
Exemple #8
0
 public bool Exists(CAR car)
 {
     return(this.CARS.Exists(t => t.Name == car.Name));
 }
Exemple #9
0
 public void Insert(int index, CAR car)
 {
     this.CARS.Insert(index, car);
 }
Exemple #10
0
 public CASE(CAR startCAR)
 {
     this.Add(startCAR);
 }