static void Main(string[] args)
        {
            Rectangle rect1  = new Rectangle(13, 13);
            Rectangle rect2  = new Rectangle(135, 130);
            Block3D   block1 = new Block3D(rect1);
            Block3D   block2 = new Block3D(rect2);

            Console.WriteLine(block2.CompareTo(block1));
        }
 public int CompareTo(object obj)
 {
     if (obj is Block3D)
     {
         Block3D other = (Block3D)obj;
         return(Rectangle.CompareTo(other.Rectangle));
     }
     return(1);
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Block3D[] blocks = new Block3D[10];
            Random    rnd    = new Random();

            for (int i = 0; i < blocks.Length; i++)
            {
                blocks[i] = new Block3D(new Rectangle(rnd.NextDouble() * 100, rnd.NextDouble() * 100), rnd.NextDouble() * 100);
            }

            Array.Sort(blocks);

            foreach (var b in blocks)
            {
                Console.WriteLine(b);
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Random random = new Random();

            Block3D[] blocks = new Block3D[10];

            for (int index = 0; index < blocks.Length; index++)
            {
                double width  = random.Next(0, 10) + random.NextDouble();
                double length = random.Next(0, 10) + random.NextDouble();

                blocks[index] = new Block3D(new Rectangle(width, length));
            }

            Array.Sort(blocks, (block1, block2) => block1.CompareTo(block2));

            foreach (var block in blocks)
            {
                Console.WriteLine(block);
            }
        }
Ejemplo n.º 5
0
        public int CompareTo(object obj)
        {
            Block3D other = (Block3D)obj;

            return(this.basis.CompareTo(other.basis));
        }