public void NeverBeenPoisonedOs() { var os = new Os("Hyper one"); var PoisonChances = new Tuple<String, Double>[1]; PoisonChances[0] = new Tuple<String, Double>("Hyper one", -1.46); var virus = new Virus("Sorry virus", PoisonChances); Assert.IsTrue(os.PoisonAttempt(virus)); }
/// Tryes to poison computer. public void Poison(Virus virus) { if (this.Os.PoisonAttempt(virus)) { this.Virus = virus; } }
public void AlwaysBeenPoisonedOs() { var os = new Os("Sorry os"); var PoisonChances = new Tuple<String, Double>[1]; PoisonChances[0] = new Tuple<String, Double>("Sorry os", 1.46); var virus = new Virus("Hyper virus", PoisonChances); Assert.IsFalse(os.PoisonAttempt(virus)); }
/// Gives provided virus os name and virus returns chance of the poisoning. /// Returns true if os got poisoned. public bool PoisonAttempt(Virus virus) { var rnd = RandomSingleton.Instance(); var chance = rnd.NextDouble(); return chance > virus.Poison(this.Name); }
/// 100 procent chance of poisoning. public new bool PoisonAttempt(Virus virus) { var rnd = new Random(); var chance = rnd.NextDouble(); return chance > virus.Poison(this.Name); }