This project is archived and is in readonly mode.

#678 ✓invalid
Daniele C.

Advance Class Usage question

Reported by Daniele C. | May 28th, 2009 @ 03:49 PM | in 2.0 (closed)

Hi all,
I was thinking, I usually create Class for easy reuse code, but, actually, I always use it in a non-static Way.
So, I've read the API and the MooTorial tring to find out a way to use class in a static way, for example, what if I want to add an internal counter for the instances created (E.g in Java I'll do:

public class MyClass{
   private static int totalInstance = 0;
   public MyClass(){
      totalInstance++;
   }
   public int getInstancesCounter(){
      return totalInstance;
   }
}

//In main
MyClass c1 = new MyClass();
MyClass c2 = new MyClass();
MyClass c3 = new MyClass();

System.out.println("Instanciated Classes: "+c1.getInstancesCounter());

)

Is there a way to do this in MooTools's classes?

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Tags

Pages