Ok so i have my main class and i have a constructor
My main method looks like thisIn the games file there are 3 values on each line there are 12 lines
The values are separated by a comma
The values on one line go like this
Game name, Developer Name, Game Rating
This is my constructor
What i want is to assign the value of the array space in address 0 to the game name and space address 1 to game developer and space address 2 to game rating in the constructor, right now all i can do is print out the values, how would i do this
public static void main(String[] args) throws IOException, FileNotFoundException {
File inFile = new File ("Games.txt");
Scanner file = new Scanner(inFile);
String str;
String[] space;
while(file.hasNext()) {
str = file.nextLine();
space = str.split(",");
for(int i=2; i < space.length; i++) {
System.out.println(space[0]);
}
}
}public class gameConst {
private String gameName;
private String gameDeveloper;
private String gameRating;
public gameConst(String gName, String gDev, String gRate) {
gameName = gName;
gameDeveloper = gDev;
gameRating = gRate;
}
}
