Airline Reservation System (go figure)

I need suggestions/advice on what to do to remove a passenger.

Page 1 of 1

1 Replies - 7062 Views - Last Post: 08 April 2010 - 01:53 AM Rate Topic: -----

#1 MISstudent2011  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 07-April 10

Airline Reservation System (go figure)

Posted 07 April 2010 - 10:08 PM

So this is for a class I'm taking. I need to figure out a logical way to remove a passenger. My code is a bit messy, but I thought I would post it just to see if I get a response. Basically I have a button to add a passenger and then one to remove one. To remove one, I figure I'll make an Input Box asking to enter their name.. then use a do loop to go through the seating chart to find their name and remove it and save the seat(row, col) to assign that seat to waitList(1). The only problem is that I'm not entirely sure how to do this in the way I have the program set up.

Public Class frmAirlineReservation

    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 btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click

        Dim row As Integer = CInt(txtRow.Text) - 1
        Dim col As Integer = Asc((txtSeat.Text).ToUpper) - 65
        Dim passenger As String = txtPassenger.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 btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
 
    End Sub
End Class



Thanks in advance. The attachment is the form view.

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Airline Reservation System (go figure)

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Airline Reservation System (go figure)

Posted 08 April 2010 - 01:53 AM

is lstSeatingChart containing the list of passenger that are in the plain. if so why dont you select the passenger you want to delete and just remove it from your listbox. that way you will be sure that this name will exit and you dont have to compare the names of all passenger with the input box string. plus a small typo in the input will make your program to give 0 result. you can try this

    Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
        lstSeatingChart.Items.RemoveAt(lstSeatingChart.SelectedIndex)

    End Sub



good luck :)

is lstSeatingChart containing the list of passenger that are in the plain. if so why dont you select the passenger you want to delete and just remove it from your listbox. that way you will be sure that this name will exit and you dont have to compare the names of all passenger with the input box string. plus a small typo in the input will make your program to give 0 result. you can try this
    Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
        lstSeatingChart.Items.RemoveAt(lstSeatingChart.SelectedIndex)
        'Add it to free seats'
    End Sub



good luck :)

This post has been edited by NoBrain: 08 April 2010 - 01:53 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1