Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Cinta_Transportadora
- Sub Main()
- Dim cola As New Queue(Of UInt16)
- Dim gente As New Queue(Of String)
- 'cola.Enqueue(5)
- 'cola.Enqueue(10)
- 'cola.Enqueue(10)
- 'Dim cad As String
- 'cad = "marcelo"
- 'Console.WriteLine(ValidarUsuario(cad))
- 'cad = "5marcelo"
- 'Console.WriteLine(ValidarUsuario(cad))
- 'cad = "mar celo"
- 'Console.WriteLine(ValidarUsuario(cad))
- 'cad = "mareeeeeeeeeeeeeeeeecelo"
- 'Console.WriteLine(ValidarUsuario(cad))
- Dim opc As Integer
- 'Do
- ' Console.WriteLine("Ingrese Peso:")
- ' opc = Console.ReadLine()
- ' ' Console.WriteLine("Cumple la condicion?: {0}", ValidarPeso(opc))
- 'Loop Until ValidarPeso(opc)
- 'Console.WriteLine("Programa Finalizado")
- 'Console.WriteLine(PesoTotal(cola))
- Do
- Console.WriteLine("Ingrese una opcion 1-Agregar, 2- Baja, 3-Ver Cinta - 0-Salir")
- If opc = 1 Then
- Agregar(cola, gente)
- ElseIf opc = 2 Then
- baja(cola, gente)
- ElseIf opc = 3 Then
- ElseIf opc = 0 Then
- Console.WriteLine("El programa Finaliza:")
- End If
- Loop While opc <> 0
- Console.ReadKey()
- End Sub
- Private Function ValidarPeso(n As Integer) As Boolean
- If n >= 1 And n <= 30 Then
- Return True
- Else
- Return False
- End If
- End Function
- Private Function PesoTotal(ByRef cola As Queue(Of UInt16)) As UInt32
- Dim a As UInt32
- For Each item In cola
- a = a + item
- Next
- Return a
- End Function
- Private Function ValidarUsuario(nom As String) As Boolean
- If Len(nom) <= 5 Or Len(nom) >= 10 Then
- Return False
- End If
- For i As Integer = 48 To 57
- If nom.ElementAt(0) = Convert.ToChar(i) Then
- Return False
- End If
- Next
- For z As Integer = 0 To Len(nom) - 1
- If nom.ElementAt(z) = Convert.ToChar(32) Then
- Return False
- End If
- Next
- Return True
- End Function
- Private Sub Agregar(ByRef cola As Queue(Of UInt16), ByRef gentes As Queue(Of String))
- Dim nom As String
- Dim pes As UInt32
- Console.WriteLine("Ingrese nombre de usuario: ")
- nom = Console.ReadLine
- Console.WriteLine("Ingrese nombre de Peso: ")
- pes = Console.ReadLine
- If ValidarUsuario(nom) And ValidarPeso(pes) Then
- cola.Enqueue(pes)
- gentes.Enqueue(nom)
- Else
- Console.WriteLine("Los Datos no son validos- reingrese")
- End If
- End Sub
- Private Sub baja(ByRef cola As Queue(Of UInt16), ByRef gentes As Queue(Of String))
- If cola.Count > 0 Then
- Console.WriteLine(cola.Dequeue())
- Console.WriteLine(gentes.Dequeue())
- End If
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement