Attached documents are in .PDF format and HAVE TO BE FOLLOWED to the letter. Pages 2 & 3 contains the UML diagram as well as how the project should look and the structure chart for the code
Last note. I am not truly sure if my DisplayReservation is what will work to use in the list box. Is there any other reference I could get to help me understand how to use a list box as the project requires.
'********************************************************
' Name: Dave Johnson
' Date: 24 November 2009
' Project: Lab 8 - Ski Lodge Reservation
' Purpose: This program takes input of name and how many nights the person staying
' then displays them in a list box and accurately caluclates the price of the total stay
'********************************************************
Public Class frmReservations
Private Sub btnReserve_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReserve.Click
'Obstantiate object
Dim objRoom As Reservation
objRoom = New Reservation
'declare variables
Dim strName As String
Dim intNights As Integer
Dim decPrice As Decimal
If IsValid(strName, intNights) Then
With objRoom
.Name = strName
.Nights = intNights
End With
'Call Display Reservation
Call DisplayReservation(objRoom, strName, intNights, decPrice)
End If
End Sub
Private Function IsValidName(ByRef strName As String) As Boolean
Dim IsValid As Boolean
Const c_MinName As Decimal = 3
Const c_MaxName As Decimal = 15
IsValid = False
If String.Length(txtName.Text, strName) AndAlso _
strName > c_MinName AndAlso strName <= c_MaxName Then
IsValid = True
End If
If IsValid = False Then
MessageBox.Show(String.Format("Name length must be bettween {0} and {1}", _
c_MinName, c_MaxName))
txtName.Focus()
txtName.SelectAll()
IsValid = False
End If
Return IsValid
End Function
Private Function IsValidNights(ByRef intNights As Integer) As Boolean
'Declare variables
Dim IsValid As Boolean
'Declare Constants
Const c_MinNights As Integer = 1
Const c_MaxNights As Integer = 30
'Reset IsValid
IsValid = False
'Validate proper entry of nights (integer)
If Integer.TryParse(txtNights.Text, intNights) AndAlso _
intNights > c_MinNights AndAlso intNights <= c_MaxNights Then
IsValid = True
End If
If IsValid = False Then
MessageBox.Show(String.Format("Please enter whole number between {0} and {1}", _
c_MinNights, c_MaxNights))
txtNights.Focus()
txtNights.SelectAll()
IsValid = False
End If
Return IsValid
End Function
Private Function IsValid(ByRef strName As String, ByRef intNights As Integer) As Boolean
Return IsValidName(strName) And IsValidNights(intNights)
End Function
Private Sub DisplayReservation(ByVal objPtr As Reservation, ByVal strName As String, ByVal intNights As Integer, ByRef decPrice As Decimal)
lstReservations.Items.Add(String.Format("{0,-15} {1,9:c} {0,9:c}", strName, intNights, decPrice))
End Sub
'Clear All data from fields.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtName.Clear()
txtNights.Clear()
lstReservations.ResetText()
txtName.Focus()
End Sub
End Class
"-------------------------------------------------------------------------------"
Public Class Reservation Private m_sName As String Public Property Name() As String Get Return m_sName End Get Set(ByVal value As String) m_sName = value End Set End Property Private m_iNights As Integer Public Property Nights() As Integer Get Return m_iNights End Get Set(ByVal value As Integer) m_iNights = value End Set End Property Public Function Price() As Decimal Return Nights * 100 End Function End Class[attachment=15076:attachment][attachment=15076:attachment]
This post has been edited by Kilborndj: 24 November 2009 - 04:15 PM

New Topic/Question
Reply




MultiQuote





|