Example #1
0
 // This is the getInstance method of the singleton.
 public static Hand PickUpObject(HoldableItem heldItem)
 {
     if (handInstance == null)
     {
         handInstance = new Hand(heldItem);
     }
     return(handInstance);
 }
Example #2
0
        public Form1()
        {
            InitializeComponent();

            rock  = new HoldableItem("Rock", 2.0);
            stick = new HoldableItem("Stick", 1.0);
            dirt  = new HoldableItem("Dirt", 0.5);
        }
Example #3
0
 // This is the instantiation, it is private to fit the model for the
 // singleton design pattern.
 private Hand(HoldableItem heldItem)
 {
     // Same as in Java differnt in C++
     this.heldItem = heldItem;
 }