Advertisement
Guest User

Parcial_1_Visual

a guest
May 28th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.05 KB | None | 0 0
  1. Module Cinta_Transportadora
  2.  
  3.     Sub Main()
  4.         Dim cola As New Queue(Of UInt16)
  5.         Dim gente As New Queue(Of String)
  6.  
  7.         'cola.Enqueue(5)
  8.         'cola.Enqueue(10)
  9.         'cola.Enqueue(10)
  10.         'Dim cad As String
  11.         'cad = "marcelo"
  12.         'Console.WriteLine(ValidarUsuario(cad))
  13.         'cad = "5marcelo"
  14.         'Console.WriteLine(ValidarUsuario(cad))
  15.         'cad = "mar celo"
  16.         'Console.WriteLine(ValidarUsuario(cad))
  17.         'cad = "mareeeeeeeeeeeeeeeeecelo"
  18.         'Console.WriteLine(ValidarUsuario(cad))
  19.         Dim opc As Integer
  20.         'Do
  21.         '    Console.WriteLine("Ingrese Peso:")
  22.         '    opc = Console.ReadLine()
  23.         '    ' Console.WriteLine("Cumple la condicion?: {0}", ValidarPeso(opc))
  24.  
  25.         'Loop Until ValidarPeso(opc)
  26.  
  27.         'Console.WriteLine("Programa Finalizado")
  28.         'Console.WriteLine(PesoTotal(cola))
  29.  
  30.         Do
  31.             Console.WriteLine("Ingrese una opcion 1-Agregar, 2- Baja, 3-Ver Cinta - 0-Salir")
  32.             If opc = 1 Then
  33.                 Agregar(cola, gente)
  34.             ElseIf opc = 2 Then
  35.                 baja(cola, gente)
  36.             ElseIf opc = 3 Then
  37.             ElseIf opc = 0 Then
  38.                 Console.WriteLine("El programa Finaliza:")
  39.             End If
  40.  
  41.         Loop While opc <> 0
  42.  
  43.  
  44.         Console.ReadKey()
  45.  
  46.     End Sub
  47.     Private Function ValidarPeso(n As Integer) As Boolean
  48.         If n >= 1 And n <= 30 Then
  49.             Return True
  50.         Else
  51.             Return False
  52.         End If
  53.     End Function
  54.     Private Function PesoTotal(ByRef cola As Queue(Of UInt16)) As UInt32
  55.         Dim a As UInt32
  56.         For Each item In cola
  57.             a = a + item
  58.         Next
  59.         Return a
  60.     End Function
  61.  
  62.     Private Function ValidarUsuario(nom As String) As Boolean
  63.  
  64.         If Len(nom) <= 5 Or Len(nom) >= 10 Then
  65.             Return False
  66.         End If
  67.  
  68.         For i As Integer = 48 To 57
  69.  
  70.             If nom.ElementAt(0) = Convert.ToChar(i) Then
  71.                 Return False
  72.             End If
  73.         Next
  74.         For z As Integer = 0 To Len(nom) - 1
  75.             If nom.ElementAt(z) = Convert.ToChar(32) Then
  76.                 Return False
  77.             End If
  78.         Next
  79.         Return True
  80.     End Function
  81.     Private Sub Agregar(ByRef cola As Queue(Of UInt16), ByRef gentes As Queue(Of String))
  82.         Dim nom As String
  83.         Dim pes As UInt32
  84.         Console.WriteLine("Ingrese nombre de usuario: ")
  85.         nom = Console.ReadLine
  86.         Console.WriteLine("Ingrese nombre de Peso: ")
  87.         pes = Console.ReadLine
  88.         If ValidarUsuario(nom) And ValidarPeso(pes) Then
  89.             cola.Enqueue(pes)
  90.             gentes.Enqueue(nom)
  91.         Else
  92.             Console.WriteLine("Los Datos no son validos- reingrese")
  93.  
  94.         End If
  95.  
  96.     End Sub
  97.     Private Sub baja(ByRef cola As Queue(Of UInt16), ByRef gentes As Queue(Of String))
  98.  
  99.         If cola.Count > 0 Then
  100.             Console.WriteLine(cola.Dequeue())
  101.             Console.WriteLine(gentes.Dequeue())
  102.         End If
  103.  
  104.     End Sub
  105. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement