View Single Post
  #5   Spotlight this post!  
Unread 18-01-2012, 17:28
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Unresponsive Code... Help Please?

Instead of:

Code:
Sweeper sweep;
It's best to have:

Code:
Sweeper sweep = Sweeper.getInstance();
Looking through your code, you don't have any getInstance() methods in Sweeper, which means you may not everything you need to have a "singleton class."

A singleton is a class that ensure that only one instance of it is ever created. The getInstance() method should check to see if a Sweeper has already been created. If it has, return that instance, if not, create a new one.

There are examples of how to make a getInstance() method to ensure your subsystems classes are all singletons. These examples can be found in the WPILib Cookbook.
__________________
In life, what you give, you keep. What you fail to give, you lose forever...
Reply With Quote