i have to create a soccer tournament like the world cup that starts off with 32 teams that goes down to 16 then quaters, semis and final i have to use sort stacks or queues or even linkedlist. there must also be arrays, classes. gui for bonus marks but i want to get the program before tackling gui. so i created a file with the 32 teams but i kind of don't know where to go from there so this is what i have.
import java.io.*;
import java.lang.*;
import java.util.*;
public class Tournament {
private Formatter File;
public void openFile(){
try{
File = new Formatter("tournament.txt");
}
catch(Exception e){
System.out.println("You have an error");
}
}
public void addRecords(){
File.format("%s %s %s %s %s %s %s %s",
"Group A","Group B", "Group C", "Group D", "Group E", "Group F", "Group G", "Group H");
File.format("\n%s %s %s %s %s %s %s %s",
"Algeria", "Argentina", "Denmark", "Honduras", "Netherlands", "Slovakia", "USA", "Japan");
File.format("\n%s %s %s %s %s %s %s %s",
"Australia", "England", "Italy", "New Zealand", "Slovenia", "Brazil", "France", "Nigeria");
File.format("\n%s %s %s %s %s %s %s %s",
"South Africa", "Cameroon", "Germany", "Korea DPR", "Paraguay", "Spain", "Chile", "Ghana");
File.format("\n%s %s %s %s %s %s %s %s",
"Korea Rep", "Portugal", "Switzerland", "Greece", "Mexico", "Serbia", "Uraguay", "Trinidad and Tobago");
}
public void closeFile(){
File.close();
}
}
the above code is for the file
this code is the main and what ever is suppose to come here but i am not sure so i tried starting with reading the file but don't know if that is the write start and getting some errors there as well.
import java.io.*;
import java.util.*;
public class Football {
public static void main(String[] args){
boolean enter;
int counter = 0;
char reply;
String Teams;
int goals;
int points;
Tournament x = new Tournament();
x.openFile();
x.addRecords();
x.closeFile();
private Scanner File;
public void openFile(){
try{
File = new Scanner(new File("tournament.txt"));
}
catch(Exception e){
System.out.println("could not find file");
}
}
public void readFile(){
while(File.hasNext()){
String a = File.next();
}
}
}
}