Hey everyone I was programing a small game and I am trying to figure out how to send an int value to a class and return a String from it.
This is my code:
This is my main.java class
public class GamGUI {
/**
* @param args
*/
public static void main(String[] args) {
int char1;
String Playername;
System.out.println("Welcome to Finaly Fantsy XXVIIV");
System.out.print("Please enter your name: ");
Scanner scan = new Scanner(System.in);
Playername = scan.nextLine();
System.out.println("Please select the Character you want to be");
System.out.println("Enter 1 for WARRIOR");
System.out.println("Enter 2 for BLACK MAGE");
System.out.println("Enter 3 for MONK RANGER");
char1 = scan.nextInt();
User.Player(char1);
System.out.println("Welcome " + Playername + " the " + User.Player(playerChar));
}
}
This i my User.java class
public class User {
public static String[] Player(int playerNumber) {
int playerHealth = 100;
int playerLevel = 1;
int playerDamage;
int playerHit;
String playerChar;
switch(playerNumber) {
case 1: playerChar = "Warrior";
break;
case 2: playerChar = "Black Mage";
break;
case 3: playerChar = "Monk Ranger";
break;
return playerChar;
}
}
}
in my main class I am trying to output " System.out.println("Welcome " + Playername + " the " + User.Player(playerChar));"... the playerChar is the string name returned from the User.java.