generated from BudDavis/TicTacToe
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
941dd80
commit e97cbce
Showing
4 changed files
with
79 additions
and
27 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
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
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
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,37 +1,72 @@ | ||
package uta.cse3310; | ||
|
||
public class Stake { | ||
private String currentStake; | ||
import java.io.BufferedReader; | ||
import java.io.FileReader; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Random; | ||
|
||
// Default constructor | ||
public Stake() { | ||
} | ||
public class Stake { | ||
private List<String> stakes; | ||
|
||
// Constructor that accepts a string argument | ||
public Stake(String currentStake) { | ||
this.currentStake = currentStake; | ||
public Stake(String filePath) throws IOException { | ||
this.stakes = new ArrayList<>(); | ||
loadStakes(filePath); | ||
} | ||
|
||
public String getCurrentStake() { | ||
return currentStake; | ||
private void loadStakes(String filePath) throws IOException { | ||
try (BufferedReader br = new BufferedReader(new FileReader(filePath))) { | ||
String line; | ||
while ((line = br.readLine()) != null) { | ||
stakes.add(line.trim()); | ||
} | ||
} | ||
} | ||
|
||
public void setCurrentStake(String currentStake) { | ||
this.currentStake = currentStake; | ||
public String getRandomStake() { | ||
Random random = new Random(); | ||
return stakes.get(random.nextInt(stakes.size())); | ||
} | ||
|
||
public void reset() { | ||
this.currentStake = null; // Or any default value | ||
this.stakes = null; // Or any default value | ||
} | ||
|
||
public int calculatePoints(char guessedLetter) { | ||
// Placeholder for actual point calculation logic | ||
// Implement your game logic here | ||
return 10; // Example fixed value, replace with actual logic | ||
public int calculatePoints(String stake, char guessedLetter) { | ||
if (stake == null) { | ||
System.err.println("Stake is null. Defaulting to 0 points."); | ||
return 0; | ||
} | ||
|
||
switch (stake) { | ||
case "Bankrupt": | ||
return 0; | ||
case "Lose Turn": | ||
return 0; | ||
case "Double Points": | ||
return 2 * 10; // Double points, assuming base is 10 | ||
case "Half Points": | ||
return 5; // Half points, assuming base is 10 | ||
case "Free Spin": | ||
case "Extra Turn": | ||
return 10; // Regular points | ||
default: | ||
try { | ||
return Integer.parseInt(stake); | ||
} catch (NumberFormatException e) { | ||
System.err.println("Invalid stake format: " + stake); | ||
return 0; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|