Quote:
Originally Posted by Team1605
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();
}
}
}