Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- import java.io.File;
- import java.io.FileReader;
- import java.util.*;
- import javax.swing.*;
- /**
- * Menu class, for providing a menu-based path through the program
- *
- * @author Kevin Kraydich
- * @version 4/22/15
- */
- public class Menu {
- // instance variables
- private static ArrayList<Team> team = new ArrayList<Team>();
- private static int teamNum;
- private static int[] points = new int[8];
- private static String s, teamName, out = "";
- private static Team t;
- private static Scanner in;
- public static void main(String[] args) throws IOException {
- in = new Scanner(new FileReader("program22test.txt"));
- while(in.hasNext()){
- s = in.nextLine();
- String[] vals = s.split(" ");
- teamName = vals[0];
- teamNum = Integer.parseInt(vals[1]);
- for(int i = 0; i < points.length; i++){
- points[i] = Integer.parseInt(vals[i + 2]);
- }
- t = new Team(teamNum, teamName, points);
- team.add(t);
- }
- String s = JOptionPane.showInputDialog("How would you like to sort these teams?\n1 = by team name\n2 = by team #\n3 = by average score\n4 = exit program");
- switch(s){
- case "1":
- case "2":
- case "3":
- case "4":
- default:
- for(int i = 0; i < team.size(); i++){
- out += team.get(i).toString();
- }
- JOptionPane.showMessageDialog(null,out);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement