The example "Java and Mode" The example of the book is the example of gardens and orchard. The learning design model is best to find an example in life. Here is an example of my own, it is a fast food restaurant. Examples, fast food restaurants offer a lot of food, such as noodles, rice, bread.
First, a FOOD interface is defined, and then these foods are inherited from it, defining a big kitchen, and the production of all foods, this is the concept of simple factory model I understand, the following is the source code: use system; namespace SimpleFactoryPattern {/// /// Simple Factory Model /// summary> Class SimpleFactoryPattern {// Define Food Interface Public Interface Food {// Cooking Void Cook (); // Sell Void Sell () } // Noodle Public Class Noodle: Food {Public Noodle () {Console.writeline ("/ NThe Noodle Is Made ..");} Private INT price; // Nood Noodle's Cook Method interface Implement Public Void Cook () {Console.Writeline ("/ nnoodle is cooking ...");} // noodle NOODLE SELL method interface implementation public void sell () {console.writeLine ("/ nnoodle has been silver ...");} public INT price {get {return this.price;} set {price = value;}}} // rice public class rice: food {public} {console.writeline ("/ NTHE RI CE is master .. ");} private void cook () {console.writeline (" / nrice is cooking ... ");} public void sell () {console.writeline (" / NRICE HAS BEEN Sold ... ");} public int price {get {return this.price;} set {price = value;}}} // BREAD PUBLIC CLASS BREAD: Food {Public Bread () {Console.Writeline (" / NTHE Bread is Made .... ");