/// <summary> /// demo /// </summary> /// <param name="args"></param> static void Main(string[] args) { Jar jar = new Jar(); Console.WriteLine("Initially:\n"); jar.PrintJar(); var coin001 = new Coin001(); coin001.AddToJar(jar); Console.WriteLine("\r\n\r\n\r\n\r\nAfter added 1 cent to the jar:\n"); jar.PrintJar(); }
/// <summary> /// Abstract method to add the coin to the jar. /// Due to different coins have different specification and value, we need to implement it in derived sub-class /// </summary> /// <param name="jar"></param> /// <returns>true: succeeded adding the coin to the jar</returns> public abstract bool AddToJar(Jar jar);