SQL Server knowledge center

everything about SQL Server
See also: Other Geeks@INDC

I Don’t Care How You Make BuburAyam

"I Don’t Care How You Make BuburAyam”

By : Kasim Wirama, MCDBA

 

Read this sentence carefully and understand this C# code sample after this paragraph. “I don’t care how you create me, what I want is that I get my bubur ayam. All I need to do is to call chef and I want him to make bubur ayam”

 

Public class Program

{

            Public static void Main()

            {

                        Chef chef = new Chef();

                        Food food= (Builder)Activator.CreateInstance(Type.GetType(“BuburAyam”));

                        chef.Order (food);

                        food.Restofood.ShowItems();

                        Console.ReadLine();

            }

}

 

Public class Chef

{

            Public void Order(Food food)

{

            food.Make();

}         

}

 

Public abstract class Food

{

            Protected RestaurantFood item;

            public abstract void Make();

           

            Public RestaurantFood Restofood

            {

                        Get { return RestaurantFood; }

            }

}

 

Public class BuburAyam : Food

{

            Public BuburAyam()

            {

                        item = new RestaurantFood();

                        item.price = 5000;

                        item.FoodName = “bubur ayam”;

            }

 

            Private List<string> items = new list<string>;

           

 

            Public override void Make()

            {

                        Items.add(“chicken”);

                        Items.add(“rice”);

                        item.FoodElements = items;

            }         

}

 

Public class RestaurantFood

{

            Public List<string> FoodElements = new List<string>();

            Public int Price;

            Public string FoodName;         

            Public void ShowItems ()

            {

                        Foreach(string item in items)

                        {

                                    Console.WriteLine(item);

                        }

            };

}

Share this post: | | | |
Posted: Jan 23 2008, 11:57 PM by Kasim.Wirama | with no comments
Filed under:

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required) 
Are you human?:  


Enter the numbers above: