virtual public void IAmPrinting(Soft sft) { if (sft is Game) { Console.WriteLine("This soft is Game!"); if (sft is Sapper) { Console.WriteLine("And this soft is Sapper!"); } Console.WriteLine(sft.ToString()); } else if (sft is TextProcessor) { Console.WriteLine("This soft is TextProcessor!"); if (sft is Word) { Console.WriteLine("And this soft is Word!"); } Console.WriteLine(sft.ToString()); } else if (sft is Bag) { Console.WriteLine("This soft is Virus!"); if (sft is CConficer) { Console.WriteLine("And this soft is CConficer!"); } Console.WriteLine(sft.ToString()); } else { throw new ApplicationException("This soft is undefined!"); } }
static public void HardwareChrcking(Computer pc, Soft sf) { if (pc.Hard.Memory < sf.Memory) { throw new HardwareExeption(); } if (pc.Hard.RAM < sf.RAM) { throw new HardwareExeption(); } }
static public void IsVirus(Soft sf) { if (sf is Bag) { if (sf is CConficer) { throw new MaliciousSoftware("CConficer"); } else { throw new MaliciousSoftware("Incoginto virus"); } } }
public override bool Equals(object obj) { if (obj is Soft && obj != null) { Soft temp = (Soft)obj; if (temp.Name == this.Name && temp.Type == this.Type) { return(true); } else { return(false); } } else { return(false); } }
public void Add(Soft value) { HardwareExeption.HardwareChrcking(this, value); MaliciousSoftware.IsVirus(value); software.Add(value); }