public void ChocolateBar_BreakChocolate_MoreSimpleTests() { Assert.AreEqual(24, ChocolateBar.BreakChocolate(5, 5)); Assert.AreEqual(27, ChocolateBar.BreakChocolate(7, 4)); Assert.AreEqual(0, ChocolateBar.BreakChocolate(1, 1)); Assert.AreEqual(0, ChocolateBar.BreakChocolate(0, 0), "What If I Told You There is No Chocolate?"); Assert.AreEqual(5, ChocolateBar.BreakChocolate(6, 1)); }
public void ChocolateBar_BreakChocolate_RandomTests() { for (int i = 0; i < 100; ++i) { int n = rnd.Next(0, 20); int m = rnd.Next(0, 20); int expected = solution(n, m); int actual = ChocolateBar.BreakChocolate(n, m); Assert.AreEqual(expected, actual); } }
// Use this for initialization void Start() { //instantiate chocolatebar and initialize its control class. GameObject hooksGO = GameObject.Instantiate(barPrefab, Vector3.zero, Quaternion.identity) as GameObject; ChocolateBarHooks hooks = hooksGO.GetComponent<ChocolateBarHooks>(); _bar = new ChocolateBar(hooks); //use generator factory to create a random bar. ChocolateBarGeneratorFactory factory = new ChocolateBarGeneratorFactory(); int noOfPieces = factory.NumberofPiecesRange[Random.Range(0, factory.NumberofPiecesRange.Length)]; Debug.Log("[ChocoPieceTest:Start]:{noOfPieces:" + noOfPieces.ToString() + "}"); ChocolateBarGenerator generator = factory.Create(_bar, noOfPieces); _bar.PieceList = generator.CreateBar(_bar, piecePrefab); }
static void Main(string[] args) { Sweet sweet = new Sweet("Alenka", 450, 51, 520, 0.45); SweetWithFilling sweetwf = new SweetWithFilling("Grilling", 500, 56, 540, 0.5, "Nut", 0.01); Caramel caramel = new Caramel("Chupa-Chups", 440, 55, 440, 0.52); CaramelWithFilling caramelwf = new CaramelWithFilling("Korovka", 510, 59, 490, "Milk", 0.05, 0.55); ChocolateBar chocolateBar = new ChocolateBar("Spartak", 550, 66, 550, 0.55); Truffle truffle = new Truffle("Golden night", 350, 54, 500, 0.5, "Nut", 0.01); Gift gift = new Gift("Christmas Gift", new List <ISweet>()); gift.AddSweet(sweet); gift.AddSweet(sweetwf); gift.AddSweet(caramel); gift.AddSweet(truffle); gift.AddSweet(chocolateBar); gift.AddSweet(caramelwf); gift.RemoveSweet(sweet); gift.AddSweet(sweet); Console.WriteLine("Gift price is (rubles): {0,13}", gift.GetGiftPrice()); Console.WriteLine("______________________________________"); Console.WriteLine("Total weight of gift is (gramm): {0} ", gift.GetWeight()); Console.WriteLine("______________________________________"); Console.WriteLine("Sort by weight:"); foreach (var i in gift.SortByWeight()) { Console.WriteLine("{0,20} \t {1,10}", i.Name, i.Weight); } Console.WriteLine("______________________________________"); Console.WriteLine("Find sweet by sugar: "); foreach (var i in gift.FindSweetBySugar(52, 57)) { Console.WriteLine("{0,25} \t {1,2}", i.Name, i.Sugar); } Console.ReadLine(); }
public void ChocolateBar_BreakChocolate_SimpleTests() { Assert.AreEqual(24, ChocolateBar.BreakChocolate(5, 5)); Assert.AreEqual(0, ChocolateBar.BreakChocolate(1, 1)); }