Exemple #1
0
        public Cuboid GetVolumeForOneItem()
        {
            int length = items.Where(r => r.Key.Equals("item1")).Select(n => n.Value.Length).FirstOrDefault();

            int width = items.Where(r => r.Key.Equals("item1")).Select(n => n.Value.Width).FirstOrDefault();

            int height = items.Where(r => r.Key.Equals("item1")).Select(n => n.Value.Height).FirstOrDefault();

            Cuboid volumeOneItem = new Cuboid(length, width, height);

            return(volumeOneItem);
        }
Exemple #2
0
        ////do all the properties
        //private int length;
        //private int width;
        //private int height;

        //public TotalVolume(int l, int w, int h) //this is the constructor
        //{
        //    this.length = l; //this means it refers to the length mentioned above on line 13
        //    this.width = w;
        //    this.height = h;
        //}

        //public int Length
        //{
        //    get { return length; }
        //    set
        //    {
        //        if (value > 0)
        //            length = value;
        //    }
        //}

        //public int Width
        //{
        //    get { return width; }
        //    set
        //    {
        //        if (value > 0)
        //            width = value;
        //    }
        //}

        //public int Height
        //{
        //    get { return height; }
        //    set
        //    {
        //        if (value > 0)
        //            height = value;
        //    }
        //}



        public Cuboid GetTotalVolumeNeeded()
        {
            int length = items.Max(r => r.Value.Length);

            int width = items.Max(r => r.Value.Width);

            int height = 0;

            foreach (var item in items.Values)
            {
                height += item.Height;
            }

            Cuboid totalVolumeNeeded = new Cuboid(length, width, height);

            return(totalVolumeNeeded);
        }
Exemple #3
0
        public Dictionary <string, Cuboid> GetAllCuboids()
        {
            for (int i = 0; i < numberOfItem; i++)
            {
                Console.WriteLine("Please enter the dimensions of item " + (i + 1) + ":");
                int[] dimensions = GetInput();
                Console.Clear();
                int[] dimensionsSorted = ReturnSorted(dimensions);

                int length = GetLength(dimensionsSorted);
                int width  = GetWidth(dimensionsSorted);
                int height = GetHeight(dimensionsSorted);

                Cuboid cuboid = new Cuboid(length, width, height);


                string name = "item" + (i + 1).ToString();
                items.Add(name, new Cuboid(length, width, height));
            }
            return(items);
        }