public void test_solution_givenHieghOfTheWall_returnsNumberOfBlocks(int[] given, int expected) { var target = new StoneWall(); var actual = target.solution(given); Assert.AreEqual(expected, actual); }
public void ShouldCountMinimumBlocks(int[] H, int expected) { StoneWall counter = new StoneWall(); int actual = counter.Count(H); Assert.AreEqual(expected, actual); }
public void BricksNumber_SimpleExample_7() { var heights = new int[] { 8, 8, 5, 7, 9, 8, 7, 4, 8 }; var solver = new StoneWall(); var bricksNumber = solver.BricksNumber(heights); bricksNumber.Should().Be(7); }
public void BricksNumber_DoubleHill_5() { var heights = new[] { 7, 9, 9, 8, 8, 7, 7, 9, 9, 8, 8, 7 }; var solver = new StoneWall(); var bricksNumber = solver.BricksNumber(heights); bricksNumber.Should().Be(5); }
public void BricksNumber_StepsUp_3() { var heights = new[] { 7, 7, 7, 8, 8, 8, 9, 9, 9 }; var solver = new StoneWall(); var bricksNumber = solver.BricksNumber(heights); bricksNumber.Should().Be(3); }
public void StoneWall_Should_Handle_Empty_Array() { StoneWall subject = new StoneWall(); int[] array = { }; int result = subject.solution(array); Assert.Equal(0, result); }
public void BricksNumber_AllTheSame_1() { var heightsNumber = 10; var heights = Enumerable.Range(1, heightsNumber).Select(n => heightsNumber).ToArray(); var solver = new StoneWall(); var bricksNumber = solver.BricksNumber(heights); bricksNumber.Should().Be(1); }
public void BricksNumber_MonotonicDecrease_AmountOfHeights() { var heightsNumber = 10; var heights = Enumerable.Range(1, heightsNumber).Select(n => heightsNumber - n).ToArray(); var solver = new StoneWall(); var bricksNumber = solver.BricksNumber(heights); bricksNumber.Should().Be(heightsNumber); }
public void StoneWall_Should_Handle_Two_Value_Array() { StoneWall subject = new StoneWall(); int[] array = { 1, 2 }; int result = subject.solution(array); Assert.Equal(2, result); }
public void StoneWall_Should_Process_Simple_Array() { StoneWall subject = new StoneWall(); int[] array = { 8, 8, 5, 7, 9, 8, 7, 4, 8 }; int result = subject.solution(array); Assert.Equal(7, result); }
public void StoneWallSolutionTest() { var stoneWall = new StoneWall(); int[] array = { 8, 8, 5, 7, 9, 8, 7, 4, 8 }; int result = stoneWall.Solve(array); Assert.AreEqual(7, result); array = new int[] { 2, 3, 2, 1 }; result = stoneWall.Solve(array); Assert.AreEqual(3, result); }
private void DisableStoneWalls() { for (int i = 0; i < stoneWalls.Length; i++) { StoneWall script = stoneWalls [i].GetComponent <StoneWall> (); if (PlayerPrefsManager.GetWallsDone() >= script.wallIndex) { DisableStoneWall(stoneWalls [i]); } else if (script.wallIndex <= levelsDone) { StartCoroutine(StartStoneWallAnimation(script)); } } }
/// <summary> /// Render a stonewall. /// </summary> /// <param name="stoneWall">StoneWall model</param> /// <param name="squareSize">Maximum size of the containing square</param> /// <returns></returns> private static Rectangle RenderStoneWall(StoneWall stoneWall, int squareSize) { var rectangle = new Rectangle { Height = squareSize, Width = squareSize, Fill = new VisualBrush( new PackIconMaterial { Kind = PackIconMaterialKind.FormatLineStyle, // FormatLineStyle icon looks like a stone wall Rotation = 180, // when rotated by 180 degrees Foreground = new SolidColorBrush(Colors.Gray) } ), Stroke = new SolidColorBrush(Colors.DimGray) }; return(rectangle); }
public static void Decode(string str) { string[] lines = Regex.Split(str.Substring(0, str.Length - 1), ":"); if (lines[0].StartsWith("S")) { Console.WriteLine(lines[1]); //Name Console.WriteLine(lines[2]); //Cordinate string[] cord = Regex.Split(lines[2], ","); Console.WriteLine(lines[3]); //Direction Tank t = new Tank(lines[1], Int32.Parse(cord[0]), Int32.Parse(cord[1])); Arena.AddGameObject(t.x_cordinate, t.y_cordinate, t); } else if (lines[0].StartsWith("I")) { //Initialize string player_name = lines[1]; Tank.current_player_name = player_name; //lines[2] - Brick string[] bricks = Regex.Split(lines[2], ";"); for (int i = 0; i < bricks.Length; i++) { string[] cords = Regex.Split(bricks[i], ","); BrickWall brick = new BrickWall(Int32.Parse(cords[0]), Int32.Parse(cords[1]), 0); Arena.AddGameObject(brick.x_cordinate, brick.y_cordinate, brick); } //lines[3] - Stone string[] stones = Regex.Split(lines[3], ";"); for (int i = 0; i < stones.Length; i++) { string[] cords = Regex.Split(stones[i], ","); StoneWall stone = new StoneWall(Int32.Parse(cords[0]), Int32.Parse(cords[1])); Arena.AddGameObject(stone.x_cordinate, stone.y_cordinate, stone); } //lines[4] - Water string[] waters = Regex.Split(lines[4], ";"); for (int i = 0; i < waters.Length; i++) { string[] cords = Regex.Split(waters[i], ","); Water water = new Water(Int32.Parse(cords[0]), Int32.Parse(cords[1])); Arena.AddGameObject(water.x_cordinate, water.y_cordinate, water); } } else if (lines[0].StartsWith("G")) { for(int x=0; x<10; x++) { for (int y = 0; y < 10; y++) { if (Arena.obj_map[x, y].type == Model.Type.TANK || Arena.obj_map[x, y].type == Model.Type.BRICK || Arena.obj_map[x, y].type == Model.Type.FLOOR) { Arena.obj_map[x, y] = new Floor(x, y); } if(Arena.obj_map[x, y].type == Model.Type.COIN) { Coin c = (Coin)Arena.obj_map[x, y]; c.Update(); } if (Arena.obj_map[x, y].type == Model.Type.LIFE) { Life l = (Life)Arena.obj_map[x, y]; l.Update(); } } } for (int i = 0; i < lines.Length; i++) { if (lines[i].StartsWith("G")) { } else if (lines[i].StartsWith("P")) { string[] player = Regex.Split(lines[i], ";"); //Tank t = new Tank(player[0], Int32.Parse(player[2])); Tank t = Tank.getTank(player[0]); t.setDirection(Int32.Parse(player[2])); string[] cord = Regex.Split(player[1], ","); t.x_cordinate = Int32.Parse(cord[0]); t.y_cordinate = Int32.Parse(cord[1]); t.shot = Int32.Parse(player[3]); t.health = Int32.Parse(player[4]); t.coins = Int32.Parse(player[5]); t.points = Int32.Parse(player[6]); Arena.AddGameObject(t.x_cordinate, t.y_cordinate, t); } else { //Brick wall updates string[] walls = Regex.Split(lines[i], ";"); for (int j = 0; j < walls.Length; j++) { string[] wall = Regex.Split(walls[j], ","); if(Int32.Parse(wall[2]) != 4) { BrickWall b = new BrickWall(Int32.Parse(wall[0]), Int32.Parse(wall[1]), Int32.Parse(wall[2])); Arena.AddGameObject(b.x_cordinate, b.y_cordinate, b); } } } } }else if (lines[0].StartsWith("C")) { string[] cord = Regex.Split(lines[1], ","); Coin c = new Coin(Int32.Parse(cord[0]), Int32.Parse(cord[1]), Int32.Parse(lines[2]), Int32.Parse(lines[3])); Arena.AddGameObject(c.x_cordinate, c.y_cordinate, c); }else if (lines[0].StartsWith("L")) { string[] cord = Regex.Split(lines[1], ","); Life l = new Life(Int32.Parse(cord[0]) , Int32.Parse(cord[1]), Int32.Parse(lines[2])); Arena.AddGameObject(l.x_cordinate, l.y_cordinate, l); }else if (lines[0].Equals("TOO_QUICK#")) { return; } Arena.UpdateArena(); if (AI.ai_status) { AI.run(); } Arena.UpdateArena(); }
public void Initialize() { _stoneWall = new StoneWall(); }
public void ShouldWork(int[] skyline, int expected) { var result = StoneWall.GetNumberOfBlocks(skyline); Assert.Equal(expected, result); }
IEnumerator StartStoneWallAnimation(StoneWall sw) { yield return new WaitForSeconds (stoneWallDelay); sw.StartStoneWallAnimation (); }
public override BaseObject fullCopy() { StoneWall other = MemberwiseClone() as StoneWall; return(other); }
// Adding and accessing stone walls public void addStoneWall(StoneWall s) { StoneWalls.Add(s.Location, s); }
IEnumerator StartStoneWallAnimation(StoneWall sw) { yield return(new WaitForSeconds(stoneWallDelay)); sw.StartStoneWallAnimation(); }