Note that there are some explanatory texts on larger screens.

plurals
  1. POPredict who will win between two teams based on their history
    primarykey
    data
    text
    <p>So I have a project due on saturday (I started last week saturday). The project is a sports prediction program.</p> <p>I spent all of yesterday researching and getting all the information on the EPL (English Premier League) so I have all the results and fixtures in a database. As well as their current statistics (average goals per game, total wins, losses, league points, etc.)</p> <p>I am currently comparing how many games they have won. What it does is retrieve data from the database from their 2 games over the season (they play 2 against every team, for those who don't watch soccer). It will either retrieve a "1" for a draw, or a name such as "Man Utd" for both games, or "Man Utd" and "Man City" for one game each. </p> <p>How do I write the logic to predict which team is going to win on who won what? ie: Man Utd beat Man City and Man City beat Man utd, which is a 50-50 chance in the next game, but Man Utd beat Swansea twice, so Man Utd has a 90% chance of beating them in the next game.</p> <p>Here is my code, which always comes out with a "50-50" so I dont know where I am going wrong.</p> <p>This may be trivial, but not for me, please help as I am representing my school at a University where there will be scouts...</p> <pre><code>/**** get the result of the first game ****/ public String getGame1Result(String team1, String team2) throws SQLException{ String resultOfGame = null; conn = DriverManager.getConnection(connection.conn_url, connection.conn_user, connection.conn_pass); statement = conn.prepareStatement("SELECT games_winner, games_draw FROM games WHERE games_team1 = '" + team2 + "' AND games_team2 = '" + team1 + "'"); result = statement.executeQuery(); while(result.next()){ System.out.println(result.getString(1)); System.out.println(result.getString(2)); if(result.getString(1) == null){ resultOfGame = result.getString(2); } else if(result.getString(2) == null) { resultOfGame = result.getString(1); } else { resultOfGame = "Did not work"; } } return resultOfGame; } /**** get the result of the second game ****/ public String getGame2Result(String team1, String team2) throws SQLException{ String resultOfGame = null; conn = DriverManager.getConnection(connection.conn_url, connection.conn_user, connection.conn_pass); statement = conn.prepareStatement("SELECT games_winner, games_draw FROM games WHERE games_team1 = '" + team1 + "' AND games_team2 = '" + team2 + "'"); result = statement.executeQuery(); while(result.next()){ System.out.println(result.getString(1)); System.out.println(result.getString(2)); if(result.getString(1) == null){ resultOfGame = result.getString(2); } else if(result.getString(2) == null) { resultOfGame = result.getString(1); } else { resultOfGame = "Did not work"; } } return resultOfGame; } /**** compare the winner result ****/ private void compareGameWinnerResult(String game1Result, String game2Result, String team1, String team2) { if((game1Result == "1") || (game2Result == "1")){ // checks for a draw System.out.println("draw"); team1_winner_result = (float) 50; team2_winner_result = (float) 50; } // } else if((game1Result.equals(team1)) &amp;&amp; (game2Result.equals(team1))) { // checks for a winner of both games // team1_winner_result = (float) 75; // team2_winner_result = (float) 25; // } else if((game1Result.equals(team2)) &amp;&amp; (game2Result.equals(team2))){ // checks for a winner of both games team1_winner_result = (float) 25; team2_winner_result = (float) 75; } else if((game1Result.equals(team1) &amp;&amp; (game2Result == null))){ // checks for a winner and a draw team1_winner_result = (float) 75; team2_winner_result = (float) 25; } else if ((game1Result == null) &amp;&amp; (game2Result.equals(team1))){ // checks for a winner and a draw team1_winner_result = (float) 25; team2_winner_result = (float) 75; } else if((game1Result.equals(team2) &amp;&amp; (game2Result == null))){ // checks for a winner and a draw team1_winner_result = (float) 75; team2_winner_result = (float) 25; } else if ((game1Result == null) &amp;&amp; (game2Result.equals(team2))){ // checks for a winner and a draw team1_winner_result = (float) 25; team2_winner_result = (float) 75; }else { // last resort team1_winner_result = (float) 50; team2_winner_result = (float) 50; } System.out.println(team1 + " " + team1_winner_result); System.out.println(team2 + " " + team2_winner_result); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload