IPenalties
Páginas: 6 (1447 palabras)
Publicado: 28 de septiembre de 2015
jugador se incluyen todas las propiedades tanto de portero como de lanzador. Sólo en lanzador y
portero tengo una función distinta (aunque realmente es igual he visto conveniente separarlas)
Friend MustInherit Class Jugador
Private pDestreza As Double
Private pAzar As Double
Private pDireccion AsBoolean
Private pEfectividad As Integer
Friend Property Destreza() As Double
Get
Return pDestreza
End Get
Set(ByVal value As Double)
pDestreza = value
End Set
End Property
Friend Property Azar() As Double
Get
Return pAzar
End Get
Set(ByVal value As Double)
pAzar = value
End Set
End Property
Friend Property Direccion() As Boolean
Get
Return pDireccion
End Get
Set(ByVal value As Boolean)
pDireccion =value
End Set
End Property
Friend Property Efectividad() As Integer
Get
Return pEfectividad
End Get
Set(ByVal value As Integer)
pEfectividad = value
End Set
End Property
Friend Sub DireccionSiAleat()
Randomize()
Dim aleatorio As Double = CInt(Math.Floor((1 - 0 + 1) * Rnd())) + 0
If aleatorio = 1 Then
'Si dirección es false, es IZQUIERDA.
Me.Direccion = False
ElseIf aleatorio = 0 Then
'Si direccion estrue, es DERECHA.
Me.Direccion = True
End If
End Sub
End Class
Friend NotInheritable Class Portero
Inherits Jugador
Friend Sub New()
End Sub
Friend Sub setEfectividad()
Me.Efectividad = CInt(Me.Destreza * Me.Azar)
End Sub
End Class
Friend NotInheritable Class Lanzador
Inherits Jugador
Friend Sub New()
End Sub
Friend Sub setEfectividad()
Me.Efectividad = CInt(Me.Destreza * Me.Azar)
End Sub
EndClass
Public NotInheritable Class Resultado
Friend Shared Function getResultado(ByVal Player As Jugador, ByVal GoalKeeper As
Portero) As Boolean
Dim miresultado As Boolean 'Si al final devuelve true (GOL). Si al final
devuelve false(Parada)
If GoalKeeper.Efectividad = Player.Efectividad Then
miresultado = False
ElseIf GoalKeeper.Efectividad > Player.Efectividad Then
miresultado = False
ElseIfPlayer.Efectividad > GoalKeeper.Efectividad Then
miresultado = True
End If
Return miresultado
End Function
End Class
Y el módulo, evidentemente:
Module Module1
Sub Main()
'Generar número entre 1 y 6 ALEATORIO
'Dim value As Integer = CInt(Int((6 * Rnd()) + 1))
Randomize()
Dim flag As Boolean = True
Dim flag2 As Boolean = True
Dim messi As New Lanzador
Dim opcion As Integer
Dim casillas As NewPortero
Dim direccion As Integer
Dim difefectividades As Integer
While flag = True
While flag2 = True
Try
Console.WriteLine("¿Desea ser portero o jugador?")
Console.WriteLine("1.- Deseo ser Casillas")
Console.WriteLine("2.- Deseo ser Messi")
Console.WriteLine("3.-Deseo que te vayas a tomar por saco. No
quiero jugar a esto.")
opcion = Console.ReadLine()
If opcion < 1 Or opcion > 3 Then
Throw NewSystem.Exception
End If
flag2 = False
Catch ex As NoNullAllowedException
Console.WriteLine("No ha introducido nada" + ex.ToString)
Catch ex As InvalidCastException
Console.WriteLine("La opción debe ser un número entero entre 1 y
3. Mira el menú bien")
Catch ex As System.Exception
Console.WriteLine("Número fuera de intervalo")
Finally
Console.WriteLine("")
Console.WriteLine("Pulse una tecla paracontinuar")
Console.WriteLine("")
Console.ReadLine()
End Try
End While
flag2 = True
Select Case opcion
Case 1
messi.Destreza = 78
messi.Azar = Rnd()
messi.DireccionSiAleat()
messi.setEfectividad()
casillas.Azar = Rnd()
casillas.Destreza = 84
casillas.setEfectividad()
While flag2 = True
Try
Console.WriteLine("¿Hacia que dirección desea tirarse?")
Console.WriteLine(" 1.- Hacia la izquierda ")Console.WriteLine(" 2.- Hacia la derecha ")
direccion = Console.ReadLine
If direccion = 0 Then
Throw New NoNullAllowedException
End If
If direccion <> 1 And direccion <> 2 Then
Throw New Exception
End If
flag2 = False
Catch ex As NoNullAllowedException
Console.WriteLine("Valor introducido nulo")
Catch ex As InvalidCastException
Console.WriteLine("Sólo puede introducir números, ó el 1 ó
el 2.")
Catch ex As...
Leer documento completo
Regístrate para leer el documento completo.