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(); }
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); }
public void Add(CAR car) { this.CARS.Add(car); if (car.IsEnd) { this.IsEnd = true; } }
public void AddNextCAR(CAR car) { this.NextCARs.Add(car); }
public CASE_Builder(CAR startCAR) { this.StartCAR = startCAR; }
public bool EndWith(CAR car) { return(this.EndCAR == car); }
public bool StartWith(CAR car) { return(this.StartCAR == car); }
public bool Exists(CAR car) { return(this.CARS.Exists(t => t.Name == car.Name)); }
public void Insert(int index, CAR car) { this.CARS.Insert(index, car); }
public CASE(CAR startCAR) { this.Add(startCAR); }