-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDriverHang.java
36 lines (31 loc) · 1.07 KB
/
DriverHang.java
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
//Torbert, e-mail: [email protected], website: www.mr.torbert.com
//version 4.5.2003
import javax.swing.JFrame;
import java.io.*; //the File class
import java.util.*; //the Scanner class
import javax.swing.JOptionPane;
import java.util.Arrays;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class DriverHang
{
public static void main(String[] args) throws Exception
{
String level = JOptionPane.showInputDialog("Enter \"easy\", \"medium\", or \"hard\"");
Scanner scan = new Scanner(new File(level+ ".txt"));
int size = scan.nextInt();
int rand = (int)(Math.random()*size);
String target = "";
for(int k=0;k<rand;k++)
{
target = scan.next();
}
JFrame frame = new JFrame("Final Project: Hangman");
frame.setSize(500, 500);
frame.setLocation(500, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(new PanelHang(target));
frame.setVisible(true);
}
}