-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
114 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,148 @@ | ||
import java.util.Scanner; | ||
|
||
import java.io.*; | ||
import java.util.ArrayList; | ||
import java.util.NoSuchElementException; | ||
|
||
public class FileReader | ||
public class FileReader | ||
|
||
{ | ||
|
||
// 100A 2 | ||
// 1 10 5000 | ||
// 5 50 10000 | ||
// 100A 2 | ||
|
||
// 1 10 5000 | ||
|
||
// 5 50 10000 | ||
|
||
public static void loadGameFile() { | ||
|
||
public static void loadGameFile() | ||
{ | ||
int numGames; | ||
|
||
int gameType; | ||
|
||
int minBet, maxBet; | ||
|
||
String fileName = "games-1.txt"; | ||
|
||
try | ||
{ | ||
Scanner scan = new Scanner(new File(fileName)); | ||
String dummy = scan.next(); //eat up the game type. | ||
numGames = scan.nextInt(); //eat up the number of games | ||
|
||
while(scan.hasNext()) | ||
|
||
String dummy = scan.next(); // eat up the game type. | ||
|
||
numGames = scan.nextInt(); // eat up the number of games | ||
|
||
while (scan.hasNext()) | ||
|
||
{ | ||
|
||
gameType = scan.nextInt(); | ||
|
||
minBet = scan.nextInt(); | ||
|
||
maxBet = scan.nextInt(); | ||
|
||
Mainpp.gameList.add(new Game(Integer.toString(gameType),minBet, maxBet)); | ||
|
||
Game g1=new Game(Integer.toString(gameType), minBet, maxBet); | ||
|
||
Mainpp.gameList.add(g1); | ||
} | ||
} | ||
catch(FileNotFoundException e) | ||
|
||
} | ||
|
||
catch (FileNotFoundException e) | ||
|
||
{ | ||
|
||
System.out.println("File was not found!"); | ||
|
||
} | ||
|
||
catch(NoSuchElementException e) | ||
|
||
catch (NoSuchElementException e) | ||
|
||
{ | ||
|
||
System.out.println("There is no such element exception!"); | ||
|
||
} | ||
catch(IOException e) | ||
|
||
catch (IOException e) | ||
|
||
{ | ||
|
||
System.out.println("Input/Output exception!"); | ||
|
||
} | ||
|
||
} | ||
public void getAllPlayersFromFile() { | ||
int PlayerType; | ||
|
||
int id=-1; | ||
|
||
int cash; | ||
String First="no",Last="no", Name=""; | ||
|
||
String fileName = "players-1.txt"; | ||
|
||
try { | ||
|
||
Scanner scan = new Scanner(new File(fileName)); | ||
while(scan.hasNext()) { | ||
PlayerType=scan.nextInt(); | ||
cash=scan.nextInt(); | ||
if(PlayerType==0) { | ||
Player c1=new NormalPlayer(cash); | ||
Implementation.waitingPlayers.add(c1); | ||
//.out.println(c1.printPlayer()); | ||
} | ||
else | ||
{ | ||
id=scan.nextInt(); | ||
First=scan.next(); | ||
Last=scan.next(); | ||
Name=First+" "+Last; | ||
if(PlayerType==1) { | ||
Player a1=new VIPPlayer(Name,cash,Integer.toString(id)); | ||
Implementation.waitingPlayers.add(a1); | ||
//System.out.println(a1.printPlayer()); | ||
} | ||
else { | ||
Player b1=new SuperVIPPlayer(Name,cash,Integer.toString(id)); | ||
Implementation.waitingPlayers.add(b1); | ||
//System.out.println(b1.printPlayer()); | ||
} | ||
|
||
} | ||
} | ||
|
||
|
||
} | ||
} | ||
|
||
catch (FileNotFoundException e) | ||
|
||
{ | ||
|
||
System.out.println("File was not found!"); | ||
|
||
} | ||
|
||
catch (NoSuchElementException e) | ||
|
||
{ | ||
|
||
System.out.println("There is no such element exception!"); | ||
|
||
} | ||
|
||
catch (IOException e) | ||
|
||
{ | ||
|
||
System.out.println("Input/Output exception!"); | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
|
||
|
||
} |