This is what i have so far. Not sure if i\'m doing it quite right. public void b
ID: 3648547 • Letter: T
Question
This is what i have so far. Not sure if i'm doing it quite right.public void buildArray (String inString)
{
mystates = new States[100]; // Created the array
nElems = 0; // no items yet
name = inString.substring (0,15).trim();
capital = inString.substring (15,30).trim();
abbrev = inString.substring (30,32).trim();
pop = inString.substring (32,40).trim();
population = Integer.parseInt (pop);
region = inString.substring (40,55).trim();
regNum = Integer.parseInt (inString.substring(55,56));
insert (name, capital, abbrev, population, region, regNum);
} //End build array
Explanation / Answer
here is a sample example public enum CellType { EMPTY, WALL, POWERUP } Scanner s = new Scanner(new File("map.txt")); CellType[][] map = new CellType[8][8]; while (s.hasNext()) { String value = s.next().toUpperCase(); int x = s.nextInt(); int y = s.nextInt(); map[x][y] = CellType.valueOf(value); }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.