Subscribe to Lucky's Thoughts        RSS Feed
-----

Let's have a coffee together

Icon Leave Comment
I got my idea from AdamSpeight2008's member title: MrCupOfT
Spoiler


So let's have a cup of coffee together:
Option Strict Off 'I am on "Coffee Break" after all ;-)
Module CoffeeBreak
    Public Sub Main()
        Dim myCoffee As New Cup(Of Coffee)
        Console.Write("{0}: {1}{2}: {3}",
                      myCoffee.GetType.Name,
                      myCoffee.MyType.Name,
                      If(myCoffee.MyCup.Milk, " with milk", ""),
                      myCoffee.ToDrink.Invoke)

        Console.ReadLine()
    End Sub

    Class Cup(Of T)
        Public ToDrink As Func(Of String) = Function() """Gulp, gulp, gulp,... aaaaahhhh!"""
        Public MyType As Type = GetType(T)
        Public MyCup As Object

        Public Sub New()
            MyCup = IIf(Me.MyType.Name = "Coffee",
                        New Coffee,
                        Nothing)
        End Sub
    End Class

    Public Class Coffee
        Public ReadOnly Milk? As Boolean

        Public Sub New(Optional withMilk? As Boolean = True)
            Me.Milk = withMilk
        End Sub
    End Class
End Module



How was your coffee break?

0 Comments On This Entry

 

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

September 2014

S M T W T F S
 123456
78910111213
1415161718 19 20
21222324252627
282930    

Tags

Recent Entries

Recent Comments

Search My Blog

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)

Categories