3 Replies - 1976 Views - Last Post: 14 April 2016 - 02:03 PM

#1 pineapple42  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-April 16

Airplane reservation - cannot remove passengers or add to waitlist

Posted 14 April 2016 - 12:49 PM

This is what I have so far.. please help asap
Public Class Form1
    Dim seat(9, 3) As String
    Dim waitingList(9) As String

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DisplaySeatingChart(seat)
    End Sub

    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim row As Integer = CInt(rowBox.Text) - 1
        Dim col As Integer = Asc((colBox.Text).ToUpper) - 65
        Dim passenger As String = nameBox.Text
        Dim numPassengers As Integer = 0
        If (row >= 0 And row <= 9) And (col >= 0 And col <= 3) Then
            If numPassengers = 39 Then
                MessageBox.Show("Flight Full.  You will be added the to waiting list")
                AddToWaitingList(passenger)
            Else
                If seat(row, col) <> "" Then
                    MessageBox.Show("Seat is occupied, please choose another one.")
                Else
                    seat(row, col) = passenger
                    lstseatingchart.Items.Clear()
                    DisplaySeatingChart(seat)
                    numPassengers = numPassengers + 1
                End If
            End If
        Else : MessageBox.Show("Please enter a valid row and/or seat.")
        End If
    End Sub


    Sub DisplaySeatingChart(ByVal seat(,) As String)
        Dim rowStr As String = ""
        For row As Integer = 0 To 9
            rowStr = ""
            For seatPosition As Integer = 0 To 3
                If seat(row, seatPosition) = "" Then
                    rowStr &= "."
                Else
                    rowStr &= "X"
                End If
                'Add a space to represent the aisle  
                If seatPosition = 1 Then
                    rowStr &= " "
                End If
            Next
            lstseatingchart.Items.Add(rowStr)
        Next
    End Sub

    Sub AddToWaitingList(ByRef passenger As String)
        'Adds passenger to waiting list  
        Dim waitingCount As Integer = 0
        If (waitingCount < 99) Then
            waitingCount += 1
            waitingList(waitingCount - 1) = passenger
        End If
        For i As Integer = 0 To waitingCount - 1
            lstwaiting.Items.Add(waitingList(i))
        Next
    End Sub


    Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        lstseatingchart.Items.RemoveAt(lstseatingchart.SelectedIndex)
    End Sub



End Class


Is This A Good Question/Topic? 0
  • +

Replies To: Airplane reservation - cannot remove passengers or add to waitlist

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13545
  • View blog
  • Posts: 54,057
  • Joined: 12-June 08

Re: Airplane reservation - cannot remove passengers or add to waitlist

Posted 14 April 2016 - 12:51 PM

Please explain what is/isn't happening.
Was This Post Helpful? 0
  • +
  • -

#3 pineapple42  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-April 16

Re: Airplane reservation - cannot remove passengers or add to waitlist

Posted 14 April 2016 - 12:56 PM

when a passenger and seat row and column is added, it does appear in the seating chart list box, but it will not delete a passenger or add anyone to waitlist listbox

View Postmodi123_1, on 14 April 2016 - 12:51 PM, said:

Please explain what is/isn't happening.



the directions are as follows:

Write a reservation system for an airline flight. Assume the airplane has 10 rows with 4 seats in each row. Use a two dimensional array of strings to maintain a seating chart. In addition, create an array to be used as a waiting list in case the plane is full. The waiting list should be “first come first serve” that is people who are added early in the list get the priority over those who are added later. Allow the user to choose from three options.
1. Add a passenger to the seat or waiting list.
a. Request the passenger’s name.
b. Display a chart of the seats in the airplane in a tabular form.
c. If seats are available let the passenger choose a seat. Add the passenger to the seating chart.
d. If no seats are available, place the passenger on the waiting list.

2. Remove a passenger from the list
a. Request the passengers name
b. Search the seating chart for the passenger’s name and delete it.
c. If the waiting list is empty, update the array so that seat is available
d. If the waiting list is not empty remove the first person from the list, and give him/her the newly vacated seat.
3. Quit
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13545
  • View blog
  • Posts: 54,057
  • Joined: 12-June 08

Re: Airplane reservation - cannot remove passengers or add to waitlist

Posted 14 April 2016 - 02:03 PM

Is this really VB6 or VB.NET?

Where's the code where you remove anything in the object 'seat'?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1