Esempio n. 1
0
        public static void Main(string[] args)
        {
            ArrayList cubeList = new ArrayList();

            string[] lines = System.IO.File.ReadAllLines("input.txt");

            foreach (string line in lines)
            {
                Point[]  points = new Point[8];
                double[] coords = line.Split(',').Select(double.Parse).ToArray();

                for (int i = 0; i <= coords.Length - 3; i += 3)
                {
                    points[i / 3] = new Point(coords[i], coords[i + 1], coords[i + 2]);
                }

                try
                {
                    Entities.Cube cube = new Entities.Cube(
                        points[0], points[1], points[2], points[3],
                        points[4], points[5], points[6], points[7]);
                    cubeList.Add(cube);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Such a cube does not exist");
                }
            }

            foreach (Entities.Cube cube in cubeList)
            {
                Console.WriteLine($"Cube:\n{cube.ToString()}\nVolume: {cube.Volume}\nBase area: {cube.BaseArea}");
            }
        }
Esempio n. 2
0
        public void CorrectCube()
        {
            Point a  = new Point(0, 0, 0);
            Point b  = new Point(0, 0, 1);
            Point c  = new Point(1, 0, 1);
            Point d  = new Point(1, 0, 0);
            Point a1 = new Point(0, 1, 0);
            Point b1 = new Point(0, 1, 1);
            Point c1 = new Point(1, 1, 1);
            Point d1 = new Point(1, 1, 0);

            Cube.Entities.Cube cube = new Cube.Entities.Cube(a, b, c, d, a1, b1, c1, d1);
            Assert.AreEqual(1, cube.Volume);
            Assert.AreEqual(1, cube.BaseArea);
        }