I have a file (part of our textbook authors’ algs4_data.zip file) in which each
ID: 3775963 • Letter: I
Question
I have a file (part of our textbook authors’ algs4_data.zip file) in which each line is the name of a team, followed by a list of all the players on it, separated by ‘/’ characters. Your job is to create two symbol tables, one that maps teams to players, and one that maps players to teams, and fill them with that data.
I will provide the code that reads the file; you need to fill in the rest. If it helps, you may assume that (a) no team is listed twice, and (b) no player is listed twice within the roster for a given team. Hint: The values obviously need to be some collection class, which means there’s something special you’ll need to do the first time you add an entry for a given team or player. This means you also need to be able to detect when you’re adding a team or player for the first time. Here is the code I’m providing to read the file. You need to fill in the blocks described by the larger comment blocks. *Could you explain this portion in detail not sure what it's asking* Syntax doesn't have to be exact since you may not have jar file containing the authors code.
import edu.princeton.cs.algs4.*;
public class ESPN {
public static void main(String[] args) {
In in = new In( "teams.txt" );
///////////////////////////////////////////////////////////////////
// Create two symbol tables, one to map teams to players, and one to
// map players to teams. You may choose one of the authors' symbol
// table implementations, or use the generic ST API as if it were
// an implemented class.
///////////////////////////////////////////////////////////////////
// Read the input file.
while(in.hasNextLine()) {
// Split the line by '/' characters. The movie is the first
// item; the remaining items are all names of actors.
String[] a = in.readLine().split("/");
///////////////////////////////////////////////////////////////////
// At this point, a[0] is the team name, and the remaining
// entries in a are names of players on that team. You need
// to add an entry to each of the two symbol tables for each
// player.
///////////////////////////////////////////////////////////////////
}
}
}
Explanation / Answer
I read the file in
than I add lines to the Team [] array in MatchManager :-
And i want to display in the GUI :-
But the display.setText(t.getTeamName()); doesnt return anything.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.