Hello,
I need to create a Basketball Simulator Which requires two teams of five players each. Each player will have an offensive rank and defensive rank (8-10) and a shooting percentage of (55-80). The rankds rankds are randomly generated and displayed on the form. This part I have accomplished.
Once the player is happy with the teams he presses a simulate button and this will trigger match-us between the two team in this manner:
1. One team is dense and the other is offense
2. One player is randomly chosen from each team
3. The defensive rank of the defensive player is compared to the offensive rank of the offensive player. If the offensive rank is higher then the offensive player gets to shoot.
4. A random number from 1 to 100 is generated. If the number is below the scoring percentage of the offensive player that team scores 3 points.
-------------------------------------------------------------------------------------
The matchup lasts 24 seconds There are 4 quarters and each quate is 12 miniutes long. The whole game should have 120 mtch-ups(12 min/24 seconds)
At this point I am having problems with selecting the player and comparing their ranks. Here's my code so far. Thanks so much for taking the time to review this. I know it is a lot.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles homeStatsBtn.Click
Dim Hplayer(4, 2) As Integer
Dim RandomGenerator As New Random
Dim OffRank As Integer
Dim DefRank As Integer
Dim ShtRank As Integer
'Generate and display random number 8-10 for off
OffRank = RandomGenerator.Next(8, 11)
hPlayer1Off.Text = Convert.ToString(OffRank)
OffRank = RandomGenerator.Next(8, 11)
hPlayer2Off.Text = Convert.ToString(OffRank)
OffRank = RandomGenerator.Next(8, 11)
hPlayer3Off.Text = Convert.ToString(OffRank)
OffRank = RandomGenerator.Next(8, 11)
hPlayer4Off.Text = Convert.ToString(OffRank)
OffRank = RandomGenerator.Next(8, 11)
hPlayer5Off.Text = Convert.ToString(OffRank)
' def ranks
DefRank = RandomGenerator.Next(8, 11)
hPlayer1Def.Text = Convert.ToString(DefRank)
DefRank = RandomGenerator.Next(8, 11)
hPlayer2Def.Text = Convert.ToString(DefRank)
DefRank = RandomGenerator.Next(8, 11)
hPlayer3Def.Text = Convert.ToString(DefRank)
DefRank = RandomGenerator.Next(8, 11)
hPlayer4Def.Text = Convert.ToString(DefRank)
DefRank = RandomGenerator.Next(8, 11)
hPlayer5Def.Text = Convert.ToString(DefRank)
'Generate and display random number from 55 - 80 for Shot %Rank
ShtRank = RandomGenerator.Next(55, 81)
hPlayer1Shts.Text = Convert.ToString(ShtRank)
ShtRank = RandomGenerator.Next(55, 81)
hPlayer2Shts.Text = Convert.ToString(ShtRank)
ShtRank = RandomGenerator.Next(55, 81)
hPlayer3Shts.Text = Convert.ToString(ShtRank)
ShtRank = RandomGenerator.Next(55, 81)
hPlayer4Shts.Text = Convert.ToString(ShtRank)
ShtRank = RandomGenerator.Next(55, 81)
hPlayer5Shts.Text = Convert.ToString(ShtRank)
ShtRank = RandomGenerator.Next(55, 81)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles guessStatsBtn.Click
Dim gplayer(4, 2) As Integer
Dim RandomGenerator As New Random
Dim OffRank As Integer
Dim DefRank As Integer
Dim ShtRank As Integer
'Generate and display random number 8-10 for off
OffRank = RandomGenerator.Next(8, 11)
gPlayer1Off.Text = Convert.ToString(OffRank)
OffRank = RandomGenerator.Next(8, 11)
gPlayer2Off.Text = Convert.ToString(OffRank)
OffRank = RandomGenerator.Next(8, 11)
gPlayer3Off.Text = Convert.ToString(OffRank)
OffRank = RandomGenerator.Next(8, 11)
gPlayer4Off.Text = Convert.ToString(OffRank)
OffRank = RandomGenerator.Next(8, 11)
gPlayer5Off.Text = Convert.ToString(OffRank)
' def ranks
DefRank = RandomGenerator.Next(8, 11)
gPlayer1Def.Text = Convert.ToString(DefRank)
DefRank = RandomGenerator.Next(8, 11)
gPlayer2Def.Text = Convert.ToString(DefRank)
DefRank = RandomGenerator.Next(8, 11)
gPlayer3Def.Text = Convert.ToString(DefRank)
DefRank = RandomGenerator.Next(8, 11)
gPlayer4Def.Text = Convert.ToString(DefRank)
DefRank = RandomGenerator.Next(8, 11)
gPlayer5Def.Text = Convert.ToString(DefRank)
'Generate and display random number from 55 - 80 for Shot %Rank
ShtRank = RandomGenerator.Next(55, 81)
gPlayer1Shts.Text = Convert.ToString(ShtRank)
ShtRank = RandomGenerator.Next(55, 81)
gPlayer2Shts.Text = Convert.ToString(ShtRank)
ShtRank = RandomGenerator.Next(55, 81)
gPlayer3Shts.Text = Convert.ToString(ShtRank)
ShtRank = RandomGenerator.Next(55, 81)
gPlayer4Shts.Text = Convert.ToString(ShtRank)
ShtRank = RandomGenerator.Next(55, 81)
gPlayer5Shts.Text = Convert.ToString(ShtRank)
ShtRank = RandomGenerator.Next(55, 81)
End Sub