Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class MathGame {
- private int operand1;
- private int operand2;
- private int solution;
- public MathGame (int operand1, int operand2)
- {
- this.operand1 = operand1;
- this.operand2 = operand2;
- }
- public int genRandom1()
- {
- Random rand = new Random();
- int randNum = rand.nextInt(0) + 20;
- randNum = operand1;
- return operand1;
- }
- public int genRandom2()
- {
- Random rand = new Random();
- int randNum2 = rand.nextInt(0) + 20;
- randNum2 = operand2;
- return operand2;
- }
- public int getoperand1()
- {
- return operand1;
- }
- public int getoperand2()
- {
- return operand2;
- }
- public String question()
- {
- return "What is" + operand1 + operand2 + "?";
- }
- public String solution()
- {
- int solution = operand1 + operand2;
- return "The correct answer is: " + solution;
- }
- }
- import java.util.Scanner;
- public class MathGameMain {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- MathGame game1 = new MathGame();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement