Megalomania Tutorial

From Progzoo
Revision as of 22:13, 21 October 2010 by Andr3w (Talk | contribs) (Created page with 'The Megalomania Tutorial requires three files: ==Megalomania.java== import java.io.*; import javax.swing.*; public class Megalomania { static Country [] world = new Country[2...')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Megalomania Tutorial requires three files:

Megalomania.java

import java.io.*; import javax.swing.*;

public class Megalomania {
 static Country [] world = new Country[262];
 public static void main(String[] args) throws Exception{
	FileReader fr = new FileReader("cia.txt");
	BufferedReader br = new BufferedReader(fr);
	for (int i=0;i<262;i++)
	{
	  String [] fld = br.readLine().split("\t");
	  world[i] = new Country(fld[0],fld[1],
					Integer.parseInt(fld[2]),
					Integer.parseInt(fld[3]),
					Long.parseLong(fld[4]));
	}
		
	String s = JOptionPane.showInputDialog("Number?");
	int n = Integer.parseInt(s);
	Country c = world[n];
	System.out.println(c.name);
  }
}