public void OpenSafe(Safe safe, Owner owner) { safe.PickLock(this); Jewels safeContents = safe.Open(writtenDownCombination); ReturnContents(safeContents, owner); }
//此处如果在子类中不写任何东西直接重写方法会引起警告相当于在方法上写new关键字,只能起隐藏方法的作用 public void ReturnContents(Jewels safeContents, Owner owner) { stolenJewels = safeContents; Console.WriteLine("I'm stealing the contents! " + stolenJewels.Sparkle()); }
public void ReturnContents(Jewels safeContents, Owner owner) { owner.ReceiveContents(safeContents); }
public void ReceiveContents(Jewels safeContents) { returnedContents = safeContents; Console.WriteLine("Thank you for returning my jewels! " + safeContents.Sparkle()); }