Trying a little personal project so I can improve on programming, and right now I am working on method calling and such. What I intend for this program to do is to randomly generate a number between 1 - 20 (I'll call it a), and another number between 1 - 400 (I'll call it b), then it will multiply a by 20, and test whether the new a is less than or equal to b, and if it is, than the victory conditions are not met, and the boolean equals false. If not, then boolean equals true. Have some issues, so came to here
Here this the actual code:
import java.util.*; public class PVP { public static void main(String[] args) { //Randomized Stats int charisma = Math.random(19) + 1; //Stat Callers int luck = Math.random(399) + 1; MakeLuck(charisma); TestLuck(luck, MakeLuck); //Victory Calculator System.out.println("Your roll: " + MakeLuck); System.out.println("Opponent: " + luck); System.out.println("Did you win? " + TestLuck); //--------------------------------------------------------------------------------------- public int MakeLuck(int test){ test *= 20; } //---------------------------------------------------------------------------------------- public boolean TestLuck(int a, int b){ if(a > b) { boolean win = true; } return win; } //--------------------------------------------------------------------------------------------- } //end of main } //end of program
Here are the errors:
C:\Users\jnhv6\Desktop\I wasn't paying attention\PVP.java:17: error: illegal start of expression public int MakeLuck(int test){ ^ C:\Users\jnhv6\Desktop\I wasn't paying attention\PVP.java:17: error: ';' expected public int MakeLuck(int test){ ^ C:\Users\jnhv6\Desktop\I wasn't paying attention\PVP.java:17: error: ';' expected public int MakeLuck(int test){ ^ C:\Users\jnhv6\Desktop\I wasn't paying attention\PVP.java:21: error: illegal start of expression public boolean TestLuck(int a, int b){ ^ C:\Users\jnhv6\Desktop\I wasn't paying attention\PVP.java:21: error: ';' expected public boolean TestLuck(int a, int b){ ^ C:\Users\jnhv6\Desktop\I wasn't paying attention\PVP.java:21: error: <identifier> expected public boolean TestLuck(int a, int b){ ^ C:\Users\jnhv6\Desktop\I wasn't paying attention\PVP.java:21: error: not a statement public boolean TestLuck(int a, int b){ ^ C:\Users\jnhv6\Desktop\I wasn't paying attention\PVP.java:21: error: ';' expected public boolean TestLuck(int a, int b){ ^ 8 errors Tool completed with exit code 1
Please assist. I would like to have multiple methods so I can have practice with them.