public void CanAttack_QueenCanReachTarget_True() { Queen queen = new Queen(8, 4); Assert.AreEqual(true, queen.CanAttack(8, 1)); Assert.AreEqual(true, queen.CanAttack(3, 4)); Assert.AreEqual(true, queen.CanAttack(6, 6)); Assert.AreEqual(false, queen.CanAttack(5, 3)); }
public void CanAttack_DiagonalUpLeftCheck_True() { //Arrange Queen queen = new Queen(4, 4); //Act bool result = queen.CanAttack(3, 5); bool result2 = queen.CanAttack(2, 6); //Assert Assert.AreEqual(true, result); Assert.AreEqual(true, result2); }
public void CanAttack_VerticalCheck_True() { //Arrange Queen queen = new Queen(4, 4); //Act bool result = queen.CanAttack(6, 4); bool result2 = queen.CanAttack(1, 4); //Assert Assert.AreEqual(true, result); Assert.AreEqual(true, result2); }
public void CanAttack_HorizontalCheck_True() { //Arrange Queen queen = new Queen(4, 4); //Act bool result = queen.CanAttack(4, 6); bool result2 = queen.CanAttack(4, 1); //Assert Assert.AreEqual(true, result); Assert.AreEqual(true, result2); }
public void CanAttack_DiagonalDownRightCheck_True() { //Arrange Queen queen = new Queen(4, 4); //Act bool result = queen.CanAttack(5, 3); bool result2 = queen.CanAttack(6, 2); //Assert Assert.AreEqual(true, result); Assert.AreEqual(true, result2); }
public void Return_Horizontal_Attack_True() { //Eventual Tests Queen queen = new Queen(2, 3); Assert.AreEqual(true, queen.CanAttack(2, 9)); }
public static void Main() { Console.WriteLine("Enter queen's X coordinate:"); string queenXCor = Console.ReadLine(); int queenXCorNumber = int.Parse(queenXCor); Console.WriteLine("Enter queen's Y coordinate:"); string queenYCor = Console.ReadLine(); int queenYCorNumber = int.Parse(queenYCor); Queen queen = new Queen(); queen.XCoordinate = queenXCorNumber; queen.YCoordinate = queenYCorNumber; Console.WriteLine("Enter piece X coordinates:"); string pieceXCor = Console.ReadLine(); int pieceXCorNumber = int.Parse(pieceXCor); Console.WriteLine("Enter piece Y coordinates:"); string pieceYCor = Console.ReadLine(); int pieceYCorNumber = int.Parse(pieceYCor); Piece piece = new Piece(); piece.XCoordinate = pieceXCorNumber; piece.YCoordinate = pieceYCorNumber; bool attacked = queen.CanAttack(pieceXCorNumber, pieceYCorNumber); if (attacked) { Console.WriteLine("This queen will get your piece"); } else { Console.WriteLine("you are safe from getting hit!"); } }
static void Main() { Console.WriteLine("Enter Queen X"); string queenCorXStr = Console.ReadLine(); int queenCorX = int.Parse(queenCorXStr); Console.WriteLine("Enter Queen Y"); string queenCorYStr = Console.ReadLine(); int queenCorY = int.Parse(queenCorYStr); Console.WriteLine("Enter Piece X"); string pieceCorXStr = Console.ReadLine(); int pieceCorX = int.Parse(pieceCorXStr); Console.WriteLine("Enter Piece Y"); string pieceCorYStr = Console.ReadLine(); int pieceCorY = int.Parse(pieceCorYStr); Queen queen = new Queen(queenCorX, queenCorY); bool attacked = queen.CanAttack(pieceCorX, pieceCorY); if (attacked) { Console.WriteLine("This queen will get ur ass"); } else { Console.WriteLine("Youre a king and got away"); } }
public void Return_Vertical_Atack_True() { //Eventual Tests Queen queen = new Queen(2, 3); Assert.AreEqual(true, queen.CanAttack(7, 3)); }
static void Main() { Console.WriteLine("Enter the current row for the queen:"); int queenRow = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the current column for the queen:"); int queenCol = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the current row for the pawn:"); int pawnRow = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the current column for the pawn:"); int pawnCol = int.Parse(Console.ReadLine()); if (queenRow == pawnRow && queenCol == pawnCol) { Console.WriteLine("The queen and the pawn cannot be on the same space, try again."); Main(); } else { Queen queen = new Queen(queenRow, queenCol); bool attacked = queen.CanAttack(pawnRow, pawnCol); if (attacked) { Console.WriteLine("The queen can attack the pawn."); } else { Console.WriteLine("The queen cannot attack the pawn."); } } }
public static void Main() { // Dictionary<string, int> xCoordinates = new Dictionary<string, int>() { {"A", 1}, {"B", 2}, {"C", 3}, {"D", 4} }; Console.WriteLine("Please input Queen's X coordinate(1 - 4)."); string inputQueenX = Console.ReadLine(); int queenX = int.Parse(inputQueenX); Console.WriteLine("Please input Queen's Y coordinate(1 - 4)."); string inputQueenY = Console.ReadLine(); int queenY = int.Parse(inputQueenY); Console.WriteLine("Please input Computer's X coordinate(1 - 4)."); string inputComputerX = Console.ReadLine(); int computerX = int.Parse(inputComputerX); Console.WriteLine("Please input Computer's Y coordinate(1 - 4)."); string inputComputerY = Console.ReadLine(); int computerY = int.Parse(inputComputerY); bool result = Queen.CanAttack(queenX, queenY, computerX, computerY); if (result) { Console.WriteLine("Queen can attack."); } else { Console.WriteLine("Queen cannot attack."); } }
public void Return_Diagonal_Attack_2nd_True() { //Eventual Tests Queen queen = new Queen(1, 1); Assert.AreEqual(true, queen.CanAttack(8, 8)); }
public void Return_Diagonal_Attack_False() { //Eventual Tests Queen queen = new Queen(2, 3); Assert.AreEqual(false, queen.CanAttack(3, 5)); }
public void Return_Diagonal_Attack_1st_True() { //Eventual Tests Queen queen = new Queen(2, 3); Assert.AreEqual(true, queen.CanAttack(4, 6)); }
public ActionResult Play() { Queen queen = new Queen(int.Parse(Request.Form["queen-position-x"]), int.Parse(Request.Form["queen-position-y"])); Queen target = new Queen(int.Parse(Request.Form["target-position-x"]), int.Parse(Request.Form["target-position-y"])); bool Attack = queen.CanAttack(queen.GetX(), queen.GetY(), target.GetX(), target.GetY()); return(View(Attack)); }
public void CanAttack_Diagonal_True() { Queen attacker = new Queen(4, 4); Queen target = new Queen(5, 3); bool result = attacker.CanAttack(attacker.GetX(), attacker.GetY(), target.GetX(), target.GetY()); Assert.AreEqual(true, result); }
public void CanAttack_Vertical_True() { Queen attacker = new Queen(6, 5); Queen target = new Queen(2, 5); bool result = attacker.CanAttack(attacker.GetX(), attacker.GetY(), target.GetX(), target.GetY()); Assert.AreEqual(true, result); }
public void CanAttack_No_False() { Queen attacker = new Queen(1, 1); Queen target = new Queen(2, 5); bool result = attacker.CanAttack(attacker.GetX(), attacker.GetY(), target.GetX(), target.GetY()); Assert.AreEqual(false, result); }
public ActionResult IndexPost() { Queen myQueen = new Queen(int.Parse(Request.Form["queen-x"]), int.Parse(Request.Form["queen-y"])); bool result = myQueen.CanAttack(int.Parse(Request.Form["victim-x"]), int.Parse(Request.Form["victim-y"])); if (result) { return(View("index", "That is a valid move.")); } else { return(View("index", "That is not a valid move.")); } }
static void Main() { Console.WriteLine("Enter the current row for the queen:"); int queenRow = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the current column for the queen:"); int queenCol = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the current row for the pawn:"); int pawnRow = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the current column for the pawn:"); int pawnCol = int.Parse(Console.ReadLine()); // //Jacqueline's abandoned attempt at drying up the code above// // int queenRow = 0; // int queenCol = 0; // int pawnRow = 0; // int pawnCol = 0; // int[] coordinates = { queenRow, queenCol, pawnRow, pawnCol }; // Dictionary<string, int> chessCoords = new Dictionary<string, int>() { {"queenRow", 0}, {"queenCol", 0}, {"pawnRow", 0}, {"pawnCol", 0}}; // string[,] chessSetup = new string[,] { {"queen", "row"}, {"queen", "column"}, {"pawn", "row"}, {"pawn", "column"}}; // for (int i = 0; i < 4; i++) // { // Console.WriteLine("Enter the current " + chessSetup[i, 0] + " " + chessSetup[i, 1]); // chessCoords = int.Parse(Console.ReadLine()); // } if (queenRow == pawnRow && queenCol == pawnCol) { Console.WriteLine("The queen and the pawn cannot be on the same space, try again."); Main(); } else { Queen queen = new Queen(queenRow, queenCol); bool attacked = queen.CanAttack(pawnRow, pawnCol); if (attacked) { Console.WriteLine("The queen can attack the pawn."); } else { Console.WriteLine("The queen cannot attack the pawn."); } } }
public ActionResult Result() { string msg = ""; int qx = Int32.Parse(Request.Form["qx"]); int qy = Int32.Parse(Request.Form["qy"]); int vx = Int32.Parse(Request.Form["vx"]); int vy = Int32.Parse(Request.Form["vy"]); if (qx < 1 || qx > 8 || qy < 1 || qy > 8) { msg = "Queen cannot be at those Coordinates"; } else if (vx < 1 || vx > 8 || vy < 1 || vy > 8) { msg = "Victim cannot be at those Coordinates"; } else if (qx == vx && qy == vy) { msg = "Queen and Victim cannot share Coordinates"; } else { Queen queen = new Queen(qx, qy); if (queen.CanAttack(vx, vy)) { msg = "Queen Takes Piece!!!"; } else { msg = "Queen cannot attack piece :("; } } Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("msg", msg); model.Add("qx", qx); model.Add("qy", qy); model.Add("vx", vx); model.Add("vy", vy); return(View("Index", model)); }
public void IsCanAttack_XandYTheSame_True() { Queen testQueen = new Queen(); Assert.AreEqual(true, testQueen.CanAttack(3, 4)); }
public void IsCanAttack_Diagonal_True() { Queen testQueen = new Queen(); Assert.AreEqual(true, testQueen.CanAttack(2, 6)); }
public void CanAttack_SameCoordinatePair_true() { Queen testQueen = new Queen(2, 4, 2, 4); Assert.AreEqual(true, testQueen.CanAttack()); }
public void CanAttack_Vertically_true() { Queen testQueen = new Queen(2, 1, 1, 2); Assert.AreEqual(true, testQueen.CanAttack()); }
public void CanAttack_Diagonally_true() { Queen testQueen = new Queen(2, 4, 6, 4); Assert.AreEqual(true, testQueen.CanAttack()); }
public void CanAttack_Horizontally_true() { Queen testQueen = new Queen(2, 4, 2, 6); Assert.AreEqual(true, testQueen.CanAttack()); }
public void QueenCanAttack_diagonal_True() { Queen testQueen = new Queen(1, 3); Assert.AreEqual(true, testQueen.CanAttack(4, 0)); }
public void QueenCanAttack_offline_false() { Queen testQueen = new Queen(1, 3); Assert.AreEqual(false, testQueen.CanAttack(2, 5)); }
public static bool CanAttack(Queen white, Queen black) => white.CanAttack(black);