Dictionary <int, int> iDDic = new Dictionary <int, int>(); //sparar de olika unika ID numrerna public WareHouse() //konstruktor för WareHouse som skapar tomma WareHouseLocations i 2D arrayen när den WareHouse instansieras { for (int i = 0; i < wareHouseLocation.GetLength(0); i++) { for (int j = 0; j < wareHouseLocation.GetLength(1); j++) { var temp = new WareHouseLocation(); wareHouseLocation[i, j] = temp; } } }
internal WareHouseLocation Content() { var storageSpace = new SortedSet <I3DObject>(new UtilitySort()); foreach (var box in this.wareHouseStorage) { I3DObject clone = box.Clone() as I3DObject; storageSpace.Add(clone); } var storage = new WareHouseLocation(); storage.wareHouseStorage = storageSpace; storage.MaxVolume = this.MaxVolume; storage.MaxWeight = this.MaxWeight; return(storage); }
public WareHouse() { try { facility = RetreaveWareHouse(); Id = GetCurrentId(); } catch { facility = new WareHouseLocation[Levels, Locations]; this.Id = 0; for (int level = 1; level < facility.GetLength(0); level++) { for (int locations = 1; locations < facility.GetLength(1); locations++) { facility[level, locations] = new WareHouseLocation(); } } } }
public bool Move(int id, int level, int location) { //Hitta lådans nuvarande plats och ta ut allt innehåll på platsen int[] oldLocation = Peek(id); if (oldLocation[0] == 0 || oldLocation[1] == 0) { return(false); } WareHouseLocation storage = facility[oldLocation[0], oldLocation[1]]; //Ta ut lådan ur nuvarande plats object newBox = -1; I3DObject boxToAdd; bool success = false; foreach (var box in storage.wareHouseStorage) { if (box.Id == id) { newBox = box.Clone(); boxToAdd = newBox as I3DObject; //Försök lägga till lådan på ny plats success = facility[level, location].TryAdd(boxToAdd); if (success) { //Ta bort den gamla lådan var oldBox = box; storage.wareHouseStorage.Remove(oldBox); return(success); } } } return(success); }