For an assignment I'm currently working on, I've encountered a brick wall with data classes and using a second .java file to grab class names from and input data and values to.
I've attempted using the original String and int names that are set to private, on top of constructor names and getters + setters.
The main file I'm trying to input data into:
public class HighScores {
/*
* Method for all content related to reading the gamescore.java file
*/
public static void readGameScore(Scanner in) {
GameScore gScore;
System.out.println("Please Enter your Username");
gScore.getUserName = sc.next();
}
Secondary (data class file) I'm trying to grab set values in
public class GameScore {
//Variable Declarations
private String Username; // The users' Username/nickname
private int gameId; // The ID of the game
private int score; // The users score
private String title; //Title, dependant on the score
//Constructor (initialise variable values)
public GameScore(String userName, int gID, int scoreValue, String scoreTitle) {
Username = userName;
//gameId = gID;
//score = scoreValue;
//title = scoreTitle;
}
/* Getters and Setters */
//Username Getter + Setter
public String getUsername() {
return Username;
}
public void setUsername (String userName) {
Username = userName;
}
gScore.getUserName = sc.next();withgScore.setUsername(sc.next());