Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit 18690e77 authored by 63160228's avatar 63160228
Browse files

tor

parent 88b6a2bf
Branches master
No related tags found
No related merge requests found
...@@ -4,6 +4,14 @@ ...@@ -4,6 +4,14 @@
*/ */
package com.zack.oxoop; package com.zack.oxoop;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* *
* @author acer * @author acer
...@@ -17,9 +25,45 @@ public class OXGameUI extends javax.swing.JFrame { ...@@ -17,9 +25,45 @@ public class OXGameUI extends javax.swing.JFrame {
initComponents(); initComponents();
this.o = new Player('O'); this.o = new Player('O');
this.x = new Player('X'); this.x = new Player('X');
load();
showWelcome(); showWelcome();
newGame(); newGame();
} }
private void load(){
FileInputStream fis = null;
try {
File file = new File("players.dat");
fis = new FileInputStream(file);
ObjectInputStream ois = new ObjectInputStream(fis);
o =(Player) ois.readObject();
x =(Player) ois.readObject();
// System.out.println(o);
// System.out.println(x);
ois.close();
fis.close();
} catch (FileNotFoundException ex) {
o=new Player('o');
x=new Player('o');
} catch (IOException ex) {
} catch (ClassNotFoundException ex) {
} finally {
try {
if(fis!=null){
fis.close();
}
} catch (IOException ex) {
}
}
System.out.println(o);
System.out.println(x);
}
/** /**
* This method is called from within the constructor to initialize the form. * This method is called from within the constructor to initialize the form.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment