public static string B(string input) { SeatingPlan seats = new SeatingPlan(input); seats.LoSIterateTillStatic(); return(seats.PersonCount().ToString()); }
/// <summary> /// 僅讀取席位資訊。 /// </summary> public void LoadTemplate(int index) { SeatingPlan sp = new SeatingPlan(seatingPlanName); JsonUtility.FromJsonOverwrite(LoadResourceTextfile("Template/" + index.ToString()), sp); seatingPlan = sp; Save(); Load(); }
private void Start() { //檢查並載入資料 seatingPlan = new SeatingPlan(seatingPlanName); if (CheckData(seatingPlanName)) { Load(); } else { LoadTemplate(0);//載入預設檔案 } }
/// <summary> /// 根據席位配製增加新成員到空間中。 /// </summary> private void AddNewMember(SeatingPlan seatingPlan) { for (int i = 0; i < seatingPlan.seats.Count; i++) { RoleInfo roleInfo = seatingPlan.seats[i].role; if (roleInfo != null && !string.IsNullOrEmpty(roleInfo.id)) { var c = roleCreator.CreateRole(roleInfo); c.transform.SetParent(objectCreatedArea.transform); Character character = c.GetComponent <Character>(); character.Init(seatingPlan.seats[i]); characterCommander.AddMember(character);//將其依附在指揮官下 } } }
private void EntertainApi_SeatingPlan_CalculateBlockOffsets_IsCorrect(List <SpBlock> sourceBlocks, int[] resultYOffsets, int resultHeight, int resultWidth) { var item = new SeatingPlan { SpBlocks = sourceBlocks }; Assert.DoesNotThrow(item.CalculateBlockOffsets); Assert.AreEqual(resultHeight, item.Height); Assert.AreEqual(resultWidth, item.Width); for (var i = 0; i < item.SpBlocks.Count; i++) { Assert.AreEqual(resultYOffsets[i], item.SpBlocks[i].YOffset); } }
private void EntertainApi_SeatingPlan_MatchAvailabilities_IsCorrect(List <SpBlock> sourceBlocks, List <Ticket> tickets, Dictionary <int, int> resultPriceMapping, List <SpBlock> resultBlocksToCheckPerformance) { var item = new SeatingPlan { SpBlocks = sourceBlocks }; Assert.DoesNotThrow(() => item.MatchAvailabilities(tickets)); var priceMappingKeys = item.PriceMap.Keys.ToList(); var priceMappingValues = item.PriceMap.Values.ToList(); var resultPriceMappingKeys = resultPriceMapping.Keys.ToList(); var resultPriceMappingValues = resultPriceMapping.Values.ToList(); for (var i = 0; i < resultPriceMapping.Count; i++) { Assert.AreEqual(resultPriceMappingKeys[i], priceMappingKeys[i]); Assert.AreEqual(resultPriceMappingValues[i], priceMappingValues[i]); } if (resultBlocksToCheckPerformance == null) { return; } for (var i = 0; i < item.SpBlocks.Count; i++) { for (var j = 0; j < item.SpBlocks[i].SpSeats.Count; j++) { for (var k = 0; k < item.SpBlocks[i].SpSeats[j].SeatPerformances.Count; k++) { var resultPerformance = resultBlocksToCheckPerformance[i].SpSeats[j].SeatPerformances[k]; var itemPerformance = item.SpBlocks[i].SpSeats[j].SeatPerformances[k]; AssertExtension.SimplePropertyValuesAreEquals(resultPerformance, itemPerformance); } } } }
private void EntertainApi_SeatingPlan_AdjustCoordinates_IsCorrect(List <SpBlock> sourceBlocks, List <SpBlock> resultBlocks) { var item = new SeatingPlan { SpBlocks = sourceBlocks }; Assert.DoesNotThrow(item.AdjustCoordinates); for (var i = 0; i < item.SpBlocks.Count; i++) { for (var j = 0; j < item.SpBlocks[i].SpRowLabels.Count; j++) { Assert.AreEqual(resultBlocks[i].SpRowLabels[j].X, item.SpBlocks[i].SpRowLabels[j].X); Assert.AreEqual(resultBlocks[i].SpRowLabels[j].Y, item.SpBlocks[i].SpRowLabels[j].Y); } for (var j = 0; j < item.SpBlocks[i].SpSeats.Count; j++) { Assert.AreEqual(resultBlocks[i].SpSeats[j].X, item.SpBlocks[i].SpSeats[j].X); Assert.AreEqual(resultBlocks[i].SpSeats[j].Y, item.SpBlocks[i].SpSeats[j].Y); } } }
public static SeatingPlan GetActiveMovieSeatingPlan(int ActiveMovieId) { SeatingPlan _SeatingPlan = new SeatingPlan(); _SeatingPlan.Rows = new List <RowDetails>(); //retrieve the list of rows DataTable dtVenueRows = Data.Movies.GetVenueRows(ActiveMovieId); DataTable dtReservedSeats = Data.Movies.GetReservedSeats(ActiveMovieId); for (int i = 0; i < dtVenueRows.Rows.Count; i++) { DataRow drVenue = dtVenueRows.Rows[i]; RowDetails _newRow = new RowDetails(); _newRow.RowNumber = (int)drVenue["RowNumber"]; _newRow.Seats = new List <SeatDetails>(); //for each row in the venue, we want to create all the SEATS in that row //first, we create a "SEAT" for every OFFSET seat (which are with status 0) for (int j = 1; j <= (int)drVenue["SeatsOffset"]; j++) { SeatDetails seat = new SeatDetails(); seat.RowNumber = (int)drVenue["RowNumber"]; seat.PositionId = i; seat.ActualSeatNumber = 0; seat.Status = 0; _newRow.Seats.Add(seat); } //create a "SeatStatus" object for each seat. // if seat is already taken - update status to 2 for (int j = 1; j <= (int)drVenue["SeatsInRow"]; j++) { SeatDetails seat = new SeatDetails(); seat.RowNumber = (int)drVenue["RowNumber"]; seat.PositionId = j + (int)drVenue["SeatsOffset"]; seat.ActualSeatNumber = j; seat.Status = 0; //check if seat is taken if (IsReservedSeat(dtReservedSeats, seat.RowNumber, seat.ActualSeatNumber)) { seat.Status = 2; } else { seat.Status = 1; } //add the new seat the SEATS list , in the ROW _newRow.Seats.Add(seat); } //add the row to the Seating Plan _SeatingPlan.Rows.Add(_newRow); } return(_SeatingPlan); }
public static void OrganiseChaos(List <string> seats) { var seatingPlan = new SeatingPlan { SeatLayout = new List <List <char> >(), layoutHasChanged = true }; foreach (var str in seats) { var charList = new List <char>(); charList.AddRange(str); seatingPlan.SeatLayout.Add(charList); } var rowNumber = seatingPlan.SeatLayout.Count; var columnNumber = seatingPlan.SeatLayout[0].Count; var loopCount = 0; while (seatingPlan.layoutHasChanged == true) { loopCount++; var newSeatingLayout = new List <List <char> >(); seatingPlan.layoutHasChanged = false; for (var row = 0; row < rowNumber; row++) { newSeatingLayout.Add(new List <char>()); for (var column = 0; column < seatingPlan.SeatLayout[row].Count; column++) { var item = seatingPlan.SeatLayout[row][column]; newSeatingLayout[row].Add(item); var newValue = GetSeatValue(seatingPlan.SeatLayout, row, column, 5); if (item != newValue.Item1) { seatingPlan.layoutHasChanged = true; } newSeatingLayout[row][column] = newValue.Item1; } //Console.WriteLine(); } Console.WriteLine(); seatingPlan.SeatLayout = newSeatingLayout; //seatingPlan.layoutHasChanged = false; var emptySeats = 0; var occupiedSeats = 0; foreach (var row in seatingPlan.SeatLayout) { foreach (var column in row) { if (column == '#') { occupiedSeats++; } if (column == 'L') { emptySeats++; } Console.Write(column); } Console.WriteLine(); } Console.WriteLine($"Number of Empty Seats: {emptySeats}"); Console.WriteLine($"Number of Occupied Seats: {occupiedSeats}"); Console.WriteLine(); } }