public int HowManyCanFit(Location location, Box box, BoxWay boxWay) { int howMany = 0; switch (boxWay) { case BoxWay.LWH: howMany = CalculationNumber(location, box.Length, box.Width, box.Height); break; case BoxWay.LHW: howMany = CalculationNumber(location, box.Length, box.Height, box.Width); break; case BoxWay.WLH: howMany = CalculationNumber(location, box.Width, box.Length, box.Height); break; case BoxWay.WHL: howMany = CalculationNumber(location, box.Width, box.Height, box.Length); break; case BoxWay.HLW: howMany = CalculationNumber(location, box.Height, box.Length, box.Width); break; case BoxWay.HWL: howMany = CalculationNumber(location, box.Height, box.Width, box.Length); break; } return(howMany); }
private string ShowBestWayCalcutions(Location location, Box box, BoxWay boxWay) { string calculations = ""; switch (boxWay) { case BoxWay.LWH: calculations = CalculationSteps(location, box.Length, box.Width, box.Height); break; case BoxWay.LHW: calculations = CalculationSteps(location, box.Length, box.Height, box.Width); break; case BoxWay.WLH: calculations = CalculationSteps(location, box.Width, box.Length, box.Height); break; case BoxWay.WHL: calculations = CalculationSteps(location, box.Width, box.Height, box.Length); break; case BoxWay.HLW: calculations = CalculationSteps(location, box.Height, box.Length, box.Width); break; case BoxWay.HWL: calculations = CalculationSteps(location, box.Height, box.Width, box.Length); break; } return(calculations); }
static void Main(string[] args) { Location location = new Location { Height = 24, Width = 48, Length = 52 }; Box box = new Box { Height = 17, Width = 2, Length = 15 }; BoxWay boxWay = location.FindTheBestWay(box); Console.WriteLine("Location: LWH"); Console.WriteLine("Box : " + boxWay + "\n"); Console.WriteLine(location.ShowBestWayCalcutions(box, boxWay)); Console.WriteLine("Number total of boxes: " + location.HowManyCanFit(box, boxWay)); Console.WriteLine(); Location locationLeft = location.InchesLeft(box, boxWay); Console.WriteLine("Inches Left"); Console.WriteLine("L: " + locationLeft.Length); Console.WriteLine("W: " + locationLeft.Width); Console.WriteLine("H: " + locationLeft.Height); Console.WriteLine(); if (locationLeft.AdjustLocation(box, location)) { BoxWay boxWayLeft = locationLeft.FindTheBestWay(box); int howManyLeftCanFit = locationLeft.HowManyCanFit(box, boxWayLeft); if (howManyLeftCanFit > 0) { Console.WriteLine("------------ More Boxes can fit ------------"); Console.WriteLine("Box : " + boxWayLeft + "\n"); Console.WriteLine(locationLeft.ShowBestWayCalcutions(box, boxWayLeft)); Console.WriteLine("Number total of boxes: " + howManyLeftCanFit); Console.WriteLine(); } } /* * BoxWay boxWayLeft = locationLeft.FindTheBestWay(box); * int howManyLeftCanFit = locationLeft.HowManyCanFit(box, boxWayLeft); * if (howManyLeftCanFit > 0) * { * Console.WriteLine("------------ More Boxes can fit ------------"); * Console.WriteLine("\tBox : " + boxWayLeft + "\n"); * Console.WriteLine("\tNumber total of boxes: " + howManyLeftCanFit); * } */ }
public async Task <IActionResult> InchesLeft([FromBody] BoxLocation boxLocation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } BoxWay bestFit = FindTheBestWay(boxLocation.Location, boxLocation.Box); return(Ok(InchesLeft(boxLocation.Location, boxLocation.Box, bestFit))); }
public async Task <IActionResult> BestWayToFit([FromBody] BoxLocation boxLocation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } BoxWay bestFit = FindTheBestWay(boxLocation.Location, boxLocation.Box); return(Ok(bestFit.ToString())); }
public Location InchesLeft(Location location, Box box, BoxWay boxWay) { Location temp = new Location(); switch (boxWay) { case BoxWay.LWH: temp.Length = location.Length - (int)(location.Length / box.Length) * box.Length; temp.Width = location.Width - (int)(location.Width / box.Width) * box.Width; temp.Height = location.Height - (int)(location.Height / box.Height) * box.Height; break; case BoxWay.LHW: temp.Length = location.Length - (int)(location.Length / box.Length) * box.Length; temp.Width = location.Width - (int)(location.Width / box.Height) * box.Height; temp.Height = location.Height - (int)(location.Height / box.Width) * box.Width; break; case BoxWay.WLH: temp.Length = location.Length - (int)(location.Length / box.Width) * box.Width; temp.Width = location.Width - (int)(location.Width / box.Length) * box.Length; temp.Height = location.Height - (int)(location.Height / box.Height) * box.Height; break; case BoxWay.WHL: temp.Length = location.Length - (int)(location.Length / box.Width) * box.Width; temp.Width = location.Width - (int)(location.Width / box.Height) * box.Height; temp.Height = location.Height - (int)(location.Height / box.Length) * box.Length; break; case BoxWay.HLW: temp.Length = location.Length - (int)(location.Length / box.Height) * box.Height; temp.Width = location.Width - (int)(location.Width / box.Length) * box.Length; temp.Height = location.Height - (int)(location.Height / box.Width) * box.Width; break; case BoxWay.HWL: temp.Length = location.Length - (int)(location.Length / box.Height) * box.Height; temp.Width = location.Width - (int)(location.Width / box.Width) * box.Width; temp.Height = location.Height - (int)(location.Height / box.Length) * box.Length; break; } return(temp); }
public async Task <IActionResult> CompleteReport([FromBody] BoxLocation boxLocation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } BoxWay bestFit = FindTheBestWay(boxLocation.Location, boxLocation.Box); string temp = ""; temp += "Location: LWH\n"; temp += "Box : " + bestFit + "\n\n"; temp += ShowBestWayCalcutions(boxLocation.Location, boxLocation.Box, bestFit) + "\n"; temp += "Number total of boxes: " + HowManyCanFit(boxLocation.Location, boxLocation.Box, bestFit) + "\n\n"; Location locationLeft = InchesLeft(boxLocation.Location, boxLocation.Box, bestFit); temp += "Inches Left\n"; temp += "L: " + locationLeft.Length + "\n"; temp += "W: " + locationLeft.Width + "\n"; temp += "H: " + locationLeft.Height + "\n"; return(Ok(temp)); }