static void Main(string[] args) { ArrayList arr = new ArrayList(3); Parallepiped p1 = new Parallepiped(-1, 0, 0, 0, -2, 0, 0, 0, -3); Parallepiped p2 = new Parallepiped(new Vector3(1, 2, 3), new Vector3(2, 3, 1), new Vector3(3, 1, 2)); arr.Add(p1); arr.Add(p2); arr.Add(new Parallepiped("<1, 0, 0>|<0, 1, 0>|<0, 0, 1>")); Parallepiped.SortBy = Parallepiped.eSortBy.Sum_of_edge_lengths; SortAndPrint(arr); Parallepiped.SortBy = Parallepiped.eSortBy.SurfaceArea; SortAndPrint(arr); Parallepiped.SortBy = Parallepiped.eSortBy.Volume; SortAndPrint(arr); }
public int CompareTo(object _obj) { Parallepiped obj = (Parallepiped)_obj; switch (sortBy) { case eSortBy.Sum_of_edge_lengths: return((OA.Length() + OB.Length() + OC.Length()).CompareTo(obj.OA.Length() + obj.OB.Length() + obj.OC.Length())); case eSortBy.SurfaceArea: return(SurfaceArea().CompareTo(obj.SurfaceArea())); case eSortBy.Volume: return(Volume().CompareTo(obj.Volume())); } throw new Exception(); }