Go to Post GP is a measurement that can only apply to yourself. To apply it to another is unfair to that person/group. - Andrew Schreiber [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 02-05-2013, 04:33 PM
DPG2013 DPG2013 is offline
Registered User
FRC #4163
 
Join Date: Jan 2012
Location: georgia
Posts: 7
DPG2013 is an unknown quantity at this point
WPI cookbpook help

I am kind of new to Java programming and I was looking through the WPI cookbookhere and under the command robot tutorial I saw this:

public class Chassis extends Subsystem {
public static final int LEFT_MOTOR_PORT = 2;
public static final int RIGHT_MOTOR_PORT = 1;
public static final double TURN_AMOUNT = 1.0;
public static final double FORWARD_SPEED = 1.0;
private static Chassis instance = null;
private RobotDrive drive;
public static Chassis getInstance() {
if(instance == null) {
instance = new Chassis();
instance.setDefaultCommand(new DriveWithJoystick());
}
return instance;
}
private Chassis() {
drive = new RobotDrive(LEFT_MOTOR_PORT, RIGHT_MOTOR_PORT);
drive.setSafetyEnabled(false); // to simplify explanation (not good practice)
}
public void straight() {
drive.arcadeDrive(-FORWARD_SPEED, 0.0); // start driving forward
}

public void turnLeft() {
drive.arcadeDrive(0.0, TURN_AMOUNT); // start turning
}
public void driveWithJoystick() {
drive.arcadeDrive(OI.getInstance().getJoystick());
}


I pretty much understand every thing except the instance part. What is a instance and how is it being used here.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 07:41 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi