reservavuelos

Of the Tutorial Small Basic Curriculum (3.2) , we take that :
An array (Array) can be multidimensional, but a stack (Stack object) has only one dimension. You can directly access any element of an array, but can only access the top element of the stack. That is, if you want to access the last element of the stack, you have to go through all the elements from the beginning.
An array is a variable type that can store multiple values ​​at once. If you want to store the names of five users, rather than to create 5 variables, you can use only one variable to store the five names
And remember that in Small Basic the Stack object is used to store data as if it will stack plates. This object follows the principle: first in, first out
Let’s use the Array object, to write a program “Flight Reservation” (excellent example) that executes the following steps:
Reserve seating for 10 passengers.
 Display the name of each passenger and seat number
 Display the total number of seats available.
code:
  1. TextWindow.WriteLine(“Reservas de vuelos”)
  2. TotalAsientos = 10
  3. For i = 1 To TotalAsientos
  4. TextWindow.Write(“Introduzca el nombre del pasajero: “)
  5. nombre[i] = TextWindow.Read()
  6. TextWindow.WriteLine(“El número de asiento ” + i + ” está reservado para ” + nombre[i])
  7. ObtenerDetalles()
  8. EndFor
  9. Sub ObtenerDetalles
  10. If Array.GetItemCount(nombre) = TotalAsientos Then
  11. TextWindow.WriteLine(“¡No hay más asientos disponibles!”)
  12. Else
  13. Array.GetItemCount(nombre)
  14. AsientosDisponibles = TotalAsientos - Array.GetItemCount(nombre)
  15. TextWindow.WriteLine(“Número de asientos disponibles: “+ AsientosDisponibles)
  16. TextWindow.WriteLine(“”)
  17. EndIf
  18. EndSub

Deja un comentario