AlaaShaker's Weblog

// untitled …

Posts Tagged ‘Design Patterns

Secret Creator SOLVED [Problem of the Week]

with one comment

After a vigorous week of solutions to this hard problem, I will now post my solution … Read the rest of this entry »

Written by AlaaShaker

August 22, 2008 at 6:47 pm

Secret Creator [Problem of the Week]

with 29 comments

After the Design Patterns course has ended in FCIS, and following up with the wicked problems of my friend, Fouad, I decided to post a code design problem I heard lately …

class Secret
{
    // TODO: class body goes here ..
}
class Creator
{
    // TODO: class body goes here ..
}

You have two classes: Secret and Creator.

Code both classes such that no other class than Creator is allowed to instantiate a local object of Secret. In other words, I can create an object of Secret as long as this code is inside Creator. If I’m inside any other class than Creator, I can’t!!! Read the rest of this entry »

Written by AlaaShaker

August 16, 2008 at 5:05 pm