0

Hello,
in a project I'm working on I'm trying to load in the attributes/stats of soccer players. Each of the 22 players has 15 values that I need to store (330 total). I was wondering if there was a way for me to enter all these variables into a file and have them loaded in during the program, since I don't want to have 330 lines of variables sitting in the main program file. What would be the best way to go about doing this? I tried using a class, but that didn't work, unless I was doing something wrong.

Also, is there a way code files and/or resources files could be used to do this. I saw them as a template option, but I'm not sure if I'd be able to use them for variables and how I would use them.

Example variables (for 22 players):
int player1speed = 90;
int player1shootingAccuracy = 80;
.
.
.
int player1goalsScored = 12;

Also, I have a PlayerData class, where I will want to load in the variables so that each object's variables will equal one of the corresponding 330 variables.

Edited by TheBattlizer: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Momerath
0

Create a player class with all the various variables that you need. Then create a List<> of this class to hold all the players. Store the values in a file using a comma to separate values. Read them in a line at a time using String.Split to get the individual values. Store them in your class. Once you are done with a line, add that player object to your list.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.