-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTeamFrame.java
More file actions
41 lines (35 loc) · 1010 Bytes
/
Copy pathTeamFrame.java
File metadata and controls
41 lines (35 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.awt.GridLayout;
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class TeamFrame extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
@SuppressWarnings("resource")
public TeamFrame() throws IOException {
Player player;
Scanner keyboard = new Scanner(new File("src\\Hankees.txt"));
for(int num = 1; num <= 9; num++) {
player = new Player(keyboard.nextLine(), keyboard.nextDouble());
keyboard.nextLine();
addPlayerInfo(player);
}
add(new JLabel());
add(new JLabel(" ------"));
add(new JLabel("Team Batting Average:"));
add(new JLabel(PlayerPlus.findTeamAverageString()));
setTitle("The Hankees");
setLayout(new GridLayout(9, 2, 20, 3));
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setVisible(true);
}
void addPlayerInfo(Player player) {
add(new JLabel(" " + player.getName()));
add(new JLabel(player.getAverageString()));
}
}