-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPongScore.java
More file actions
45 lines (30 loc) · 997 Bytes
/
PongScore.java
File metadata and controls
45 lines (30 loc) · 997 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
42
43
44
45
import javax.swing.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
public class PongScore {
ArrayList<String> score;
PongScore(){
try {
Scanner s = new Scanner(new File("/Users/Wing/IdeaProjects/CIS 36B Final Project/src/pongScore.txt"));
score = new ArrayList<>();
// Skip column headings.
// Read each line, ensuring correct format.
while (s.hasNextLine())
{
score.add(s.nextLine());
}
} catch (FileNotFoundException e) {
e.printStackTrace();
System.out.println("file not found");
}
}
public void printScore(){
String output1 = "";
for (int i = 0; i < score.size(); i++) {
output1 += score.get(i) + "\n";
}
JOptionPane.showMessageDialog(null, output1 , "Pong Score" , JOptionPane.PLAIN_MESSAGE);
}
}