myf = new Finch();
do
{
//menu 4
if (s.equals("Tap Test")) RunTapTest(s);
}
private static void RunTapTest(String s)
{
@SuppressWarnings("resource")
Scanner reader = new Scanner(System.in);
System.out.println("Enter the time interval in which you want the Finch to move backwards: ");
//get user input for tapBack
int tapBack = reader.nextInt();
System.out.println("\n"+"Running: "+s+"\n");
long before = System.currentTimeMillis();
while(System.currentTimeMillis() - before < testtime)
{
System.out.println(myf.isTapped());
//myf.setWheelVelocities(-255,0,testtime);
}
//I can't set myf.isTapped = true
if (myf.isTapped()) {
myf.setWheelVelocities(-255,0,tapBack);
}
}
Here's the homework question:
Menu option 4 will determine if the Finch has been tapped on its tail. If so, the Finch should respond with the spoken words “Thanks” and move backwards for a user specified time interval.
I'm just trying to fix the user specified time interval (at the moment), and I'm having trouble implementing it.
If I attempt this code
if (myf.isTapped() = true) {
myf.setWheelVelocities(-255,0,tapBack);
}
I get an error on:
if (myf.isTapped() = true)
Saying
The left-hand side of an assignment must be a variable
I'm struggling on how to get the robot to move backwards if the myf.isTapped = true
Maybe myf.isTapped cannot take boolean values?
I'm using http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Scanner.html for user input (integer in this case)
Also, I think the my.isTapped is from an external Jar file.
if (myf.isTapped() == true)or even better:if (myf.isTapped())