Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

re-motion in general uses parameter lists for passing
parameters for constructors to the object factory. The
mechanism is explained in the PhoneBook tutorial for
NewObject<T> (section NewObject<T> with parameters).

For every class for which you want to have instantiation
with parameters, you must create a constructor. Let's
say you want a DessertTopping with flavors:

public enum Flavor
{
  Mint,
  Banana,
  Strawberry,
  Licorice,
  Cinnamon
}

What you need is a constructor for DessertTopping that
does the right thing:

public DessertTopping (Flavor flavor)
{
  // we assume that 'DessertTopping' now has a
  // 'Flavor Flavor' property
  Flavor = flavor;
}

You are basically set. Instantiation does **NOT** work like
this:

 
  • No labels