public void CompareTrees_DifferentSizes_MustReturnFalse() { #region Creating objects #region Tree 1 BTN tree1 = new BTN(); tree1.val = 90; tree1.left = new BTN(); tree1.left.val = 50; tree1.left.left = new BTN(); tree1.left.left.val = 20; tree1.left.right = new BTN(); tree1.left.right.val = 75; tree1.right = new BTN(); tree1.right.val = 150; #endregion #region Tree 2 BTN tree2 = new BTN(); tree2.val = 91; #endregion #endregion Assert.AreEqual(false, new TreesCompare().CompareTrees(tree1, tree2)); }
public void ShouldReturnFalseIfTreesNotEqual() { var leftSubtree = new BTN() { Value = 2 }; var rightSubtree = new BTN() { Value = 3 }; var firstTree = new BTN { Value = 1, Right = rightSubtree, Left = leftSubtree }; var secondTree = new BTN { Value = 1, Right = leftSubtree, Left = rightSubtree }; var comparisonResult = TreeComparator.Compare(firstTree, secondTree); Assert.IsFalse(comparisonResult); }
public void BTN_CompareTwoObjectWithDifferentType_ShouldReturnFalse() { var obj1 = new BTN(1, null, null); var obj2 = "Teste"; Assert.False(obj1.Equals(obj2)); }
/// <summary> /// Creates two objects. Both objects have same values. /// </summary> /// <param name="first">BTN object which will be populate.</param> /// <param name="second">BTN object which will be populate.</param> private void createSecondCaseObjects(BTN first, BTN second) { first.val = 1; first.left = new BTN { val = 2, left = new BTN { val = 3, left = null, right = null }, right = new BTN { val = 4, left = null, right = null } }; first.right = new BTN { val = 5, left = new BTN { val = 6, left = null, right = null }, right = new BTN { val = 7, left = null, right = null } }; second.val = 1; second.left = new BTN { val = 2, left = new BTN { val = 3, left = null, right = null }, right = new BTN { val = 4, left = null, right = null } }; second.right = new BTN { val = 5, left = new BTN { val = 6, left = null, right = null }, right = new BTN { val = 7, left = null, right = null } }; }
public void BTN_CompareTwoObjectsThatBothRightAndLeftAreNull_ShouldReturnTrue() { var obj1 = new BTN(1, null, null); var obj2 = new BTN(1, null, null); Assert.True(obj1.Equals(obj2)); }
public void CompareMethodTestLastCase() { BTN second = new BTN(); bool result = BinaryTreeOperations.Compare(null, second); Assert.IsFalse(result); }
/// <summary> /// 1) We have a class representing binary tree nodes: //class BTN //{ // int val; // BTN left; // BTN right; //} //please implement method to compare 2 such trees(returns: true if fully equal, false - otherwise) /// </summary> /// <param name="tree1"></param> /// <param name="tree2"></param> /// <param name="isEqual"></param> public bool CompareTrees(BTN tree1, BTN tree2) { bool areEqual = true; if (tree1 != null && tree2 != null) { areEqual = CompareTrees(tree1.left, tree2.left); if (!areEqual) { return(areEqual); } if (tree1.val != tree2.val) { return(false); } areEqual = CompareTrees(tree1.right, tree2.right); if (!areEqual) { return(areEqual); } } else if (tree1 != null && tree2 == null) { return(false); } else if (tree1 == null && tree2 != null) { return(false); } return(areEqual); }
private void btnRepeatCount_Click(object sender, RoutedEventArgs e) { //bool heh = ((Button)sender).IsPressed; //while(btnMinusBPMCount.IsPressed) //{ // SumBPMCount(1); //} BTN id = (BTN)Convert.ToInt32(((Button)sender).Uid); switch (id) { case BTN.BTN_REPEAT_PLUS: SumRepeatCount(1); break; case BTN.BTN_REPEAT_MINUS: SumRepeatCount(-1); break; case BTN.BTN_BPM_PLUS: SumBPMCount(1); break; case BTN.BTN_BPM_MINUS: SumBPMCount(-1); break; default: break; } }
public void BTN_CompareTwoObjectsThat1ObjectHasRightValueAnd2ObjectHasNullValueRight_ShouldReturnFalse() { var right = new BTN(1, null, null); var obj1 = new BTN(1, null, right); var obj2 = new BTN(1, null, null); Assert.False(obj1.Equals(obj2)); }
public void BTN_CompareTwoObjectsThat1ObjectHasLeftValueAnd2ObjectHasNullValueLeft_ShouldReturnFalse() { var left = new BTN(1, null, null); var obj1 = new BTN(1, left, null); var obj2 = new BTN(1, null, null); Assert.False(obj1.Equals(obj2)); }
public override bool Equals(object obj) { BTN _obj = (BTN)obj; return(Val == _obj.Val && object.Equals(Left, _obj.Left) && object.Equals(Right, _obj.Right)); }
public void BTN_CompareTwoObjectWithValueButRightValueIsDifferent_ShouldReturnFalse() { var right1 = new BTN(2, null, null); var right2 = new BTN(3, null, null); var obj1 = new BTN(1, null, right1); var obj2 = new BTN(1, null, right2); Assert.False(obj1.Equals(obj2)); }
public void ShouldReturnTrueIfTreesAreEmpty() { var firstTree = new BTN(); var secondTree = new BTN(); var comparisonResult = TreeComparator.Compare(firstTree, secondTree); Assert.IsTrue(comparisonResult); }
public void BTN_CompareTwoObjectWithValueButLeftValueIsEqual_ShouldReturnTrue() { var left1 = new BTN(2, null, null); var left2 = new BTN(2, null, null); var obj1 = new BTN(1, left1, null); var obj2 = new BTN(1, left2, null); Assert.True(obj1.Equals(obj2)); }
public void CompareMethodTestThirdCase() { BTN first = new BTN(); BTN second = new BTN(); this.createThirdCaseObjects(first, second); bool result = BinaryTreeOperations.Compare(first, second); Assert.IsFalse(result); }
/// <summary> /// Creates two objects. one of them will be null, other will be correct instance. /// </summary> /// <param name="first">BTN object which will be populate.</param> /// <param name="second">BTN object which will be populate.</param> private void createFirstCaseObjects(BTN first, BTN second) { first = null; second.val = 1; second.left = new BTN { val = 2, left = null, right = null }; second.right = new BTN { val = 3, left = null, right = null }; }
public void BTN_CompareTwoObjectWithValueAndBothLeftAndRightValuesAreEqual_ShouldReturnTrue() { var left1 = new BTN(3, null, null); var left2 = new BTN(3, null, null); var right1 = new BTN(2, null, null); var right2 = new BTN(2, null, null); var obj1 = new BTN(1, left1, right1); var obj2 = new BTN(1, left2, right2); Assert.True(obj1.Equals(obj2)); }
//При выборе вкладки "Добавить Аккаунт" //Создаются немного другие Элементы формы private void добавитьАккаунтToolStripMenuItem_Click(object sender, EventArgs e) { ClearForm(); Lab lb; lb = new Lab(30, labelsY, "Введите Название ресурса", 150); Label lbAddResource = lb.create(); this.Controls.Add(lbAddResource); lb = new Lab(190, labelsY, "Введите Адрес Электронной почты", 95); Label lbAddMail = lb.create(); this.Controls.Add(lbAddMail); lb = new Lab(300, labelsY, "Введите Логин", 95); Label lbAddLogin = lb.create(); this.Controls.Add(lbAddLogin); lb = new Lab(420, labelsY, "Введите Пароль", 95); Label lbAddPassword = lb.create(); this.Controls.Add(lbAddPassword); TB tb; tb = new TB(30, mainY, "", false, 150); TextBox tbAddResource = tb.create(); this.Controls.Add(tbAddResource); tb = new TB(190, mainY, ""); TextBox tbAddMail = tb.create(); this.Controls.Add(tbAddMail); tb = new TB(300, mainY, ""); TextBox tbAddLogin = tb.create(); this.Controls.Add(tbAddLogin); tb = new TB(420, mainY, ""); TextBox tbAddPassword = tb.create(); this.Controls.Add(tbAddPassword); BTN btn; btn = new BTN(540, mainY, 95, "Добавить"); Button btnAdd = btn.create(); this.Controls.Add(btnAdd); btnAdd.Click += new EventHandler(btnAdd_Click); }
private void addAccMenu_Click(object sender, EventArgs e) { ClearForm(); Lab lb; lb = new Lab(30, labelsY, "Enter Resource Name", 150); Label lbAddResource = lb.create(); this.Controls.Add(lbAddResource); lb = new Lab(190, labelsY, "Enter Mail", 95); Label lbAddMail = lb.create(); this.Controls.Add(lbAddMail); lb = new Lab(300, labelsY, "Enter Login", 95); Label lbAddLogin = lb.create(); this.Controls.Add(lbAddLogin); lb = new Lab(420, labelsY, "Enter Password", 95); Label lbAddPassword = lb.create(); this.Controls.Add(lbAddPassword); TB tb; tb = new TB(30, mainY, "", false, 150); TextBox tbAddResource = tb.create(); this.Controls.Add(tbAddResource); tb = new TB(190, mainY, ""); TextBox tbAddMail = tb.create(); this.Controls.Add(tbAddMail); tb = new TB(300, mainY, ""); TextBox tbAddLogin = tb.create(); this.Controls.Add(tbAddLogin); tb = new TB(420, mainY, ""); TextBox tbAddPassword = tb.create(); this.Controls.Add(tbAddPassword); BTN btn; btn = new BTN(540, mainY, 95, "Add"); Button btnAdd = btn.create(); this.Controls.Add(btnAdd); btnAdd.Click += new EventHandler(btnAdd_Click); }
public void The_Second_Tree_Do_Not_Have_Right_Compared_To_The_First_Not_Equals() { var firstBtn = new BTN { Val = 1, Left = new BTN { Val = 2, Left = new BTN { Val = 4 }, Right = new BTN { Val = 5 } }, Right = new BTN { Val = 3, Left = new BTN { Val = 6 }, Right = new BTN { Val = 7 } } }; var secondBtn = new BTN { Val = 1, Left = new BTN { Val = 2, Left = new BTN { Val = 4 } }, Right = new BTN { Val = 3, Left = new BTN { Val = 6 } } }; Assert.IsFalse(firstBtn.IsTreeEqualTo(secondBtn)); }
public void ShouldReturnFalseIfExactlyOneTreeIsEmpty() { var firstTree = new BTN(); var secondTree = new BTN { Value = 1 }; var comparisonResult = TreeComparator.Compare(firstTree, secondTree); Assert.IsFalse(comparisonResult); }
public void One_Of_Btn_Trees_Is_Null() { var firstBtn = new BTN { Val = 1, Left = new BTN { Val = 2 }, Right = new BTN { Val = 3 } }; firstBtn.IsTreeEqualTo(null); }
public void BTN_CompareTwoObjectHaveManyLevelsEqual_ShouldReturnTrue() { var left1_3 = new BTN(20, null, null); var right2_3 = new BTN(20, null, null); var left1_1 = new BTN(10, left1_3, right2_3); var right2_2 = new BTN(10, left1_3, right2_3); var left1 = new BTN(3, left1_1, right2_2); var left2 = new BTN(3, left1_1, right2_2); var right1 = new BTN(2, left1_1, right2_2); var right2 = new BTN(2, left1_1, right2_2); var obj1 = new BTN(1, left1, right1); var obj2 = new BTN(1, left2, right2); Assert.True(obj1.Equals(obj2)); }
static void Main(string[] args) { BTN bTN2 = new BTN(); bTN2.Val = 4; //bTN.Left = bTN2; //bTN.Right = bTN3; BTN bTN3 = new BTN(); bTN3.Val = 6; object.Equals(bTN2, bTN3); //bool asd = object.Equals(bTN2, bTN3); BTN bTN = new BTN(); bTN.Val = 1; bTN.Left = bTN2; bTN.Right = bTN3; // BTN bTN22 = new BTN(); bTN22.Val = 4; //bTN22.Left = bTN; //bTN.Left = bTN2; //bTN.Right = bTN3; BTN bTN32 = new BTN(); bTN32.Val = 6; BTN bTN12 = new BTN(); bTN12.Val = 1; bTN12.Left = bTN22; bTN12.Right = bTN32; //// bool a = bTN.Equals(bTN12); }
public static bool IsTreeEqualTo(this BTN firstTree, BTN secondTree) { if (firstTree == null && secondTree == null) { return(true); } if (firstTree == null || secondTree == null) { return(false); } if (firstTree.Val != secondTree.Val) { return(false); } return(IsTreeEqualTo(firstTree.Left, secondTree.Left) && IsTreeEqualTo(firstTree.Right, secondTree.Right)); }
private void AccPasswordStorageMenu_Click(object sender, EventArgs e) { ClearForm(); TB tb = new TB(310, mainY - 50, "", false, 150); TextBox tbNewPassword = tb.create(); tbNewPassword.PasswordChar = '*'; tbNewPassword.TextAlign = HorizontalAlignment.Center; this.Controls.Add(tbNewPassword); tb = new TB(310, mainY - 25, "", false, 150); TextBox tbNewPassCopy = tb.create(); tbNewPassCopy.PasswordChar = '*'; tbNewPassCopy.TextAlign = HorizontalAlignment.Center; this.Controls.Add(tbNewPassCopy); BTN btn = new BTN(310, mainY + 25, 150, "Change"); Button btnChangePass = btn.create(); this.Controls.Add(btnChangePass); btnChangePass.Click += new EventHandler(btnChangePass_Click); }
public BTN(int val) { this.val = val; this.right = null; this.left = null; }
private void Start() { BTN_Freeze.onClick.RemoveAllListeners(); BTN_Minus.onClick.RemoveAllListeners(); BTN_Delete.onClick.RemoveAllListeners(); BTN_Reset.onClick.RemoveAllListeners(); BTN_Leave_mission.onClick.RemoveAllListeners(); //level QA if (Level <= 10) { int Count = Random.Range(1, 5); BTNS = new GameObject[Count]; for (int i = 0; i < BTNS.Length; i++) { BTNS[i] = Instantiate(Raw_model_BTN, Place_BTNS); } } else if (Level >= 11 && Level <= 20) { int Count = Random.Range(2, 7); BTNS = new GameObject[Count]; for (int i = 0; i < BTNS.Length; i++) { BTNS[i] = Instantiate(Raw_model_BTN, Place_BTNS); } } else if (Level >= 21 && Level <= 40) { int Count = Random.Range(3, 8); BTNS = new GameObject[Count]; for (int i = 0; i < BTNS.Length; i++) { BTNS[i] = Instantiate(Raw_model_BTN, Place_BTNS); } } else if (Level >= 41) { int Count = Random.Range(3, 9); BTNS = new GameObject[Count]; for (int i = 0; i < Count; i++) { BTNS[i] = Instantiate(Raw_model_BTN, Place_BTNS); } } //insert value to btn for (int i = 0; i < BTNS.Length; i++) { BTNS[i].AddComponent <BTN>(); BTNS[i].GetComponent <BTN>().Change_value(gameObject); } BTN_Freeze.onClick.AddListener(() => { if (Freeze >= 1) { Partical_freeze.Play(); BTN_Freeze.GetComponent <AudioSource>().Play(); foreach (var BTN in BTNS) { BTN.GetComponent <BTN>().Freeze_time = 0.005f; BTN.GetComponent <BTN>().Show_anim_freeze(); } Freeze -= 1; } else { Music_reject.Play(); Partical_reject.Play(); } }); BTN_Minus.onClick.AddListener(() => { if (Minues >= 1) { BTN_Minus.GetComponent <AudioSource>().Play(); Partical_Minus.Play(); Minues -= 1; foreach (var BTN in BTNS) { if (BTN.GetComponent <BTN>().Count > 1) { if (BTN.GetComponent <BTN>().Count - 1 < BTN.GetComponent <BTN>().Tap) { BTN.GetComponent <BTN>().Tap -= 1; } BTN.GetComponent <BTN>().Count -= 1; BTN.GetComponent <BTN>().Show_anim_minuse(); } else { print("One btn cant minus"); } } } else { Music_reject.Play(); Partical_reject.Play(); } }); BTN_Delete.onClick.AddListener(() => { if (Delete >= 1 && BTNS.Length > 2) { BTN_Delete.GetComponent <AudioSource>().Play(); Partical_delete.Play(); //animation delete BTNS[BTNS.Length - 1].GetComponent <BTN>().Anim = 1; //work Delete -= 1; GameObject[] New_BTNS = new GameObject[BTNS.Length - 1]; for (int i = 0; i < New_BTNS.Length; i++) { New_BTNS[i] = BTNS[i]; } BTNS = New_BTNS; } else { Music_reject.Play(); Partical_reject.Play(); } }); BTN_Reset.onClick.AddListener(() => { if (Reset >= 1) { BTN_Reset.GetComponent <AudioSource>().Play(); Partical_reset.Play(); Reset -= 1; for (int i = 0; i < BTNS.Length; i++) { Destroy(BTNS[i]); } Start(); } else { Music_reject.Play(); Partical_reject.Play(); } }); BTN_Leave_mission.onClick.AddListener(() => { //camera action Player.Cam.Move_Camera_To_Menu(); //music controller Menu.Play_music_menu(); //destroy game play Destroy(Parent.GetComponent <Raw_model_fild_server_play>().Missions); }); Recive_data(); void Recive_data() { //recive count player Chilligames_SDK.API_Client.Recive_data_server <Panel_Servers.Model_server>(new Chilligames.SDK.Model_Client.Req_data_server { Name_app = "Venomic", _id_server = _id_server }, result => { Count_Player = (int)ChilligamesJson.DeserializeObject <Panel_Servers.Model_server.Setting_servers>(result.Setting.ToString()).Player; }, ERR => { }); // recive ranking Chilligames_SDK.API_Client.Recive_data_server <Panel_Servers.Model_server>(new Req_data_server { Name_app = "Venomic", _id_server = _id_server }, result => { var leader_board = ChilligamesJson.DeserializeObject <Panel_Servers.Model_server.Setting_servers>(result.Setting.ToString()).Leader_board; int[] score = new int[leader_board.Length]; for (int i = 0; i < leader_board.Length; i++) { score[i] = (int)ChilligamesJson.DeserializeObject <Raw_model_info_server.Deserilies_leader_board>(leader_board[i].ToString()).Score; } int curent_score = Level + Freeze + Minues + Delete + Chance + Reset; for (int i = 0; i < leader_board.Length; i++) { if (curent_score < score[i]) { Rank_player = i; } } }, err => { }); } }
public void Compare_Equal_BTN_Trees() { var firstBtn = new BTN { Val = 1, Left = new BTN { Val = 2, Left = new BTN { Val = 4, Left = new BTN { Val = 8 }, Right = new BTN { Val = 9 } }, Right = new BTN { Val = 5 } }, Right = new BTN { Val = 3, Left = new BTN { Val = 6 }, Right = new BTN { Val = 7 } } }; var secondBtn = new BTN { Val = 1, Left = new BTN { Val = 2, Left = new BTN { Val = 4, Left = new BTN { Val = 8 }, Right = new BTN { Val = 9 } }, Right = new BTN { Val = 5 } }, Right = new BTN { Val = 3, Left = new BTN { Val = 6 }, Right = new BTN { Val = 7 } } }; Assert.IsTrue(firstBtn.IsTreeEqualTo(secondBtn)); }
public void Compare_Equal_BTN_Trees_1() { var firstBtn = new BTN { Val = 8, Left = new BTN { Val = 3, Left = new BTN { Val = 1 }, Right = new BTN { Val = 6, Left = new BTN { Val = 4 }, Right = new BTN { Val = 7 } } }, Right = new BTN { Val = 10, Right = new BTN { Val = 14, Right = new BTN { Val = 13 } } } }; var secondBtn = new BTN { Val = 8, Left = new BTN { Val = 3, Left = new BTN { Val = 1 }, Right = new BTN { Val = 6, Left = new BTN { Val = 4 }, Right = new BTN { Val = 7 } } }, Right = new BTN { Val = 10, Right = new BTN { Val = 14, Right = new BTN { Val = 13 } } } }; Assert.IsTrue(firstBtn.IsTreeEqualTo(secondBtn)); }