public void Test() { Vasya vasyok = new Vasya(); Friend fr1 = new Friend(); Friend fr2 = new Friend(); Friend fr3 = new Friend(); vasyok.apples = 27; vasyok.VasyaEat(3); Console.WriteLine(vasyok.apples); //vasyok.apples = vasyok.apples - 3; double applesForEachFriend = new CalcCore().DivideMethod(vasyok.apples, 3); fr1.Eat(applesForEachFriend); fr2.Eat(applesForEachFriend); fr3.Eat(applesForEachFriend); double eatenApples = new CalcCore().PlusMethod(fr1.hasEat, fr2.hasEat); Console.WriteLine(eatenApples); eatenApples = new CalcCore().PlusMethod(eatenApples, fr3.hasEat); vasyok.apples = new CalcCore().MinusMethod(vasyok.apples, eatenApples); double er = 0; Assert.AreEqual(er, vasyok.apples); }
public void VasyaVSFriendsEatDrink() { Vasya vasyok = new Vasya(); Friend fr1 = new Friend(); Friend fr2 = new Friend(); Friend fr3 = new Friend(); Friend fr4 = new Friend(); vasyok.apples = 27; vasyok.water = 100; for (int i = 0; i < 7; i++) { vasyok.VasyaEat(3); } double applesForFriends = vasyok.apples; applesForFriends = new CalcCore().DivideMethod(applesForFriends, 4); double friendsDrinkWater = 0; for (int i = 0; i < 7; i++) { vasyok.VasyaDrink(3); fr1.Drink(4); friendsDrinkWater += 4; fr2.Drink(4); friendsDrinkWater += 4; fr3.Drink(4); friendsDrinkWater += 4; fr4.Drink(4); friendsDrinkWater += 4; } double friendsEatApples = 0; fr1.Eat(applesForFriends); friendsEatApples += applesForFriends; fr2.Eat(applesForFriends); friendsEatApples += applesForFriends; fr3.Eat(applesForFriends); friendsEatApples += applesForFriends; fr4.Eat(applesForFriends); friendsEatApples += applesForFriends; vasyok.apples -= friendsEatApples; vasyok.water -= friendsDrinkWater; Assert.AreEqual(0, vasyok.apples); Assert.AreEqual(-33, vasyok.water); }
public double calculateNew(double num1, double num2, int oper) { double res = 0; char op = 'a'; if (oper == 1) { op = '+'; } if (oper == 2) { op = '-'; } if (oper == 3) { op = '*'; } if (oper == 4) { op = '/'; } if (oper == 5) { op = 'p'; } if (oper == 6) { op = 's'; } switch (op) { case '+': return(res = new CalcCore().PlusMethod(num1, num2)); case '-': return(res = new CalcCore().MinusMethod(num1, num2)); case '*': return(res = new CalcCore().MultiplyMethod(num1, num2)); case '/': return(res = new CalcCore().DivideMethod(num1, num2)); case 'p': return(res = new CalcCore().PowMethod(num1, num2)); case 's': return(res = new CalcCore().SqrtMethod(num1)); } return(res = 0); }
public void TestDrink_3() { Vasya vasyok = new Vasya(); List <Friend> friendList = new List <Friend>(); for (int i = 0; i < amountOfFriends; i++) { friendList.Add(new Friend() { _name = "Friend_" + (i + 1) }); Console.WriteLine(friendList[i]._name); } vasyok.apples = 27; vasyok.amountOfLitersWater = 100; double totalDrunked = 0; for (int i = 0; i < amountOfDay; i++) { vasyok.VasyaEat(3); vasyok.VasyaDrink(3); for (int j = 0; j < friendList.Count; j++) { friendList[j].Drink(4); totalDrunked += 4; } } vasyok.amountOfLitersWater -= totalDrunked; double applesForEachFriend = new CalcCore().DivideMethod(vasyok.apples, amountOfFriends); double eatenApples = 0; for (int i = 0; i < amountOfFriends; i++) { friendList[i].Eat(applesForEachFriend); eatenApples += friendList[i].hasEat; } vasyok.apples -= eatenApples; double _expected_result_Water = -33; double _expected_result_Apples = 0; Assert.AreEqual(_expected_result_Water, vasyok.amountOfLitersWater); Assert.AreEqual(_expected_result_Apples, vasyok.apples); }
public void Test() { Vasya vasyok = new Vasya(); List <Friend> friendList = new List <Friend>(); for (int i = 0; i < amountOfFriends; i++) { friendList.Add(new Friend() { _name = "Friend_" + (i + 1) }); Console.WriteLine(friendList[i]._name); } vasyok.apples = 27; vasyok.VasyaEat(3); double applesForEachFriend = new CalcCore().DivideMethod(vasyok.apples, amountOfFriends); for (int i = 0; i < amountOfFriends; i++) { friendList[i].Eat(applesForEachFriend); } double eatenApples = 0; for (int i = 0; i < amountOfFriends; i++) { eatenApples = new CalcCore().PlusMethod(eatenApples, friendList[i].hasEat); } Console.WriteLine(eatenApples); vasyok.apples = new CalcCore().MinusMethod(vasyok.apples, eatenApples); double _expected_result = 0; Assert.AreEqual(_expected_result, vasyok.apples); }