Az alábbi letöltési lehetőségek közül választhatsz: (
segítség)
Típus: text/plain
Tartalmaz szöveget
Karakterkódolás: utf-8
Méret: 1 KB
package hu.krivan.szakkor.szerkezetek;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
@author
public class GrafFactory {
private static GrafFactory instance = null;
private BufferedReader input = null;
private GrafFactory() throws FileNotFoundException {
input = new BufferedReader(new FileReader("szerkezetek.be"));
}
private Graf nextGraf() throws IOException {
String s;
ArrayList<String> edges = new ArrayList<String>();
while (true) {
s = input.readLine();
if (s.equals("0 0")) {
return null;
}
if (s.equals("")) {
break;
}
edges.add(s);
}
return new Graf(edges);
}
public static Graf getNextGraf() throws FileNotFoundException, IOException {
return getInstance().nextGraf();
}
private static GrafFactory getInstance() throws FileNotFoundException {
if (instance == null) {
instance = new GrafFactory();
}
return instance;
}
}