Question Get array's to listbox in diffrent formats

vendicore

New member
Joined
Aug 17, 2013
Messages
2
Programming Experience
Beginner
Hello i am writing a cinema reservation project with 2 one dimension arrays .

at this point i am having some problems with the array.

My Question is : 'I dont know how to put my arry´s together and then place them in my listbox with the right format. I have been instructed to use GetSeatInfoStrings() function and the function GetSeatInfoAt() but do i really need them both?

The problem is in SeatManager line 40- 56 i also included the question in the code.

Some info on the project.

All user-interactions must be coded in the MainForm, but this class should not contain other logics than those related to IO (input/output).

The arrays as well as all other related logics must be coded in a separate class, SeatManager. (SeatManager.vb). The MainForm should use an instance of the SeatManager (aggregation) and communicate with the instance through the instance’s methods (and constructors).

All tasks in the SeatManager, for instance ReserveSeat, CancelSeat, GetNumberOfVacantSeats, etc. should be coded in separate methods.

Use of collections is not allowed

One of the Requirements i have is that SeatManager should store the customer names in a one-dimensional array (m_nameList) and the prices in another one-dimensional array (m_priceList). The numbering of seats in this case will be a sequence beginning from 0 to total number of seats -1.

VB.NET:
Public Class SeatManager

    Dim numofReservedSeats As Integer
    Dim numOfVacantSeats As Integer
    Private ReadOnly m_totnumofseats As Integer = 60
    Private m_nameList As String() = Nothing
    Private m_pricelist As Double() = Nothing

    Public Sub New(ByVal maxNumberOfSeats As Integer)
        m_totnumofseats = maxNumberOfSeats
        m_nameList = New String(m_totnumofseats) {}
        m_pricelist = New Double(m_totnumofseats) {}
    End Sub



    Private Function CheckIndex(ByVal index As Integer)
        If (m_nameList.Length > 59) Then
            Return False
        ElseIf (m_pricelist.Length > 59) Then
            Return False
        Else
            Return True
        End If
    End Function

    Public Function GetNumOfSeat() As Integer
        Return m_totnumofseats
    End Function


    Public Function GetNumOfReserved() As Integer
        Return 1
    End Function

    Public Function GetNumOfVacant() As Integer
        Return 2
    End Function

    Public Function GetSeatInfoAt(ByVal index As Integer) As String
        Dim strOut As String
        strOut = index
        Return strOut
    End Function

    Public Function GetSeatInfoStrings()
        Dim seats As Integer = 60
        Dim strSeatInfoStrings As String() = New String(seats - 1) {}
        Dim i As Integer = 0

        For index As Integer = 0 To m_totnumofseats - 1
            strSeatInfoStrings(index) = index
        Next
        Return strSeatInfoStrings
        'i dont know how to put my arryes together and then place them in my listbox with the right format. i've been instructed to
        'use this function and the function above GetSeatInfoAt() but do i really need them both.
    End Function

    Public Function ReservSeat(ByVal name As String, ByVal price As Double, ByVal index As Integer) As Boolean

        Return False
    End Function

    Public Function CancelSeat() As Boolean
        Return True
    End Function

    Public Sub SeatManager()

    End Sub

    Public Function checkForValidName(stringIn As String) As Boolean
        Dim strIn = stringIn.Trim()

        If (String.IsNullOrEmpty(strIn)) Then
            MsgBox("Please type your name in the namebox")
            Return False
        Else
            Return True
        End If

    End Function



End Clas
 
You haven't really explained the situation clearly. Are you saying, without actually saying, that you need to display in the ListBox the list of names with the corresponding prices next to them? If so then GetSeatInfoAt will give take an index and use that index to get an element from each array and join them together into a single String. I'm quite sure that you know how to join two Strings. GetSeatInfoStrings will use a loop to call GetSeatInfoAt for each index.

By the way, why do some of your functions have a return type and some don't? ALL functions should have a return type.
 
Back
Top