View Single Post
  #10   Spotlight this post!  
Unread 24-03-2012, 21:16
PAR_WIG1350's Avatar
PAR_WIG1350 PAR_WIG1350 is offline
Registered User
AKA: Alan Wells
FRC #1350 (Rambots)
Team Role: Alumni
 
Join Date: Dec 2009
Rookie Year: 2009
Location: Rhode Island
Posts: 1,189
PAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond repute
Re: Need Serious help !!!!

Quote:
Originally Posted by Team1605 View Post
i did nto make seperate classes how can i do tht
To make a new class you would have to add a new file to the project. Then you would have to write the code for the constructors and various methods in the class
for example:
Code:
public class Gatherer
{
   //this is the constructor
   public void Gatherer (Jaguar jag1, Jaguar jag2)
   {
      //code to set values to instance variables and create objects for use in this class
    }
   
   //these methods can be called to do stuff
   public void set(double thisSpeed)
   {
      //code to sets jags to run at thisSpeed go here
   }
However, based on your code, I would only have one class, and gatherer and shooter would both be objects of that one class.

Code:
public class MotorPair
{
   //these are instance variables
   Jaguar jaguar1, jaguar2;
   boolean isRunnung = false;

   //this is the constructor
   public void MotorPair (Jaguar jag1, Jaguar jag2)
   {
     /* jaguar1 =  jag1;
         jaguar2 =  jag2;*/
    }
   
   //these methods can be called to do stuff
   public void run()
   {
      jaguar1.set(1);
      jaguar2.set(1);
      isRunning = true;
   }

   public void stop()
   {
      jaguar1.set(0);
      jaguar2.set(0);
      isRunning = false;
   }

   public void toggle()
   {
      if (isRunning)
      {
          stop();
      }
      else
      {
          run();
       }
   }
}
__________________
Reply With Quote