Hi there.. I'm new to Java and don't fully understand yet how to call methods from other classes. If somebody could take a look at my code and offer suggestions, it'd be much appreciated. Here are my classes, Multiply and MultiplyTest:
__________________________________________________ _______
// Ch06_Assignment: MultiplyTest.java
// Author: Joshua Nelson
// Date: 3/5/2013
public class MultiplyTest
{
public static void main( String[] args )
{
Multiply myMultiply = new Multiply();
myMultiply.createQuestion();
myMultiply.quiz();
myMultiply.checkResponse(response);
} // end main
} // end class:MultiplyTest
__________________________________________________ _______
// Ch06_Assignment: Multiply.java
// Author: Joshua Nelson
// Date: 3/5/2013
import java.util.Scanner;
import java.util.Random;
public class Multiply
{
public static int product;
public static int createQuestion()
{
Random randomNumbers = new Random();
int num1 = randomNumbers.nextInt(9);
int num2 = randomNumbers.nextInt(9);
product = num1 * num2;
System.out.printf( "How much is %d times %d?", num1, num2 );
return product;
} // end method:createQuestion
public static void checkResponse( int guess )
{
if (guess != product)
System.out.println( "No. Please try again" );
else
{
System.out.println( "Very Good!" );
createQuestion();
} // end else
} // end method:checkResponse
public static int quiz()
{
createQuestion();
Scanner input = new Scanner( System.in );
System.out.println( "Enter your answer (-1 to exit):" );
int response = input.nextInt();
while (response != -1)
{
checkResponse(response);
System.out.println( "Enter your answer (-1 to exit):" );
response = input.nextInt();
} // end while
return response;
} // end method:quiz
} // end class:Multiply