|
-
Feb 8th, 2010, 11:30 PM
#1
Thread Starter
New Member
Help me with this program please!!
Here is what i need to do, and really need help on the three classes,
An Item class which contains six read-write properties but no methods. The properties are:
IDNumber, String
Description, String
DailyRate, Decimal
WeeklyRate, Decimal
MonthlyRate, Decimal
Quantity, Integer
There should be an Inventory class which contains a single Items property that contains a collection of Item objects. The methods of this class should be:
Public Sub AddItem(ByVal item As Item)
adds a new Item to the inventory
Public Function RemoveItem(ByVal id As String)
removes an Item from the inventory
Public Function GetItem(ByVal id As String) As Item
retrieves and item from the inventory
There should be an InventoryData class which is responsible for reading inventory from a text file into a collection and writing back to the text file from a collection. The text file should be placed in the App_Data folder. The class has no properties but does have private variables that hold a filename, StreamReader, and StreamWriter. The methods should be:
Public Sub New(ByVal filename As String)
constructor which initializes the inventory filename
Public Sub LoadData(ByVal inven As Inventory)
opens and loads the inventory file into the inventory collection
Public Sub SaveData(ByVal invent As Inventory)
opens and saves the inventory collection into the inventory file
Private Function ReadOneItem( ) As Item
reads one item from the inventory file and returns an Item object
this is a "helper" function for LoadData
Private Sub WriteOneItem(ByVal item As Item)
writes an Item object to the inventory file
this is a "helper" function for SaveData
Here is what i did so far in the item class, i am not sure if i have the right code???
Code:
Imports Microsoft.VisualBasic
Public Class Item
Private mIDNum As String
Private mDescription As String
Private mDailyRate As Decimal
Private mWeeklyRate As Decimal
Private mMonthlyRate As Decimal
Private mQuantity As Integer
Public Property IDNum() As String
Get
Return mIDNum
End Get
Set(ByVal inIDNum As String)
mIDNum = inIDNum
End Set
End Property
Public Property Description() As String
Get
Return mDescription
End Get
Set(ByVal inDescription As String)
mDescription = inDescription
End Set
End Property
Public Property DailyRate() As Decimal
Get
Return mDailyRate
End Get
Set(ByVal inDailyRate As Decimal)
If inDailyRate > 0 Then
mDailyRate = inDailyRate
End If
End Set
End Property
Public Property WeeklyRate() As Decimal
Get
Return mWeeklyRate
End Get
Set(ByVal inWeeklyRate As Decimal)
If inWeeklyRate > 0 Then
mWeeklyRate = inWeeklyRate
End If
End Set
End Property
Public Property MonthlyRate() As Decimal
Get
Return mMonthlyRate
End Get
Set(ByVal inMonthlyRate As Decimal)
If inMonthlyRate > 0 Then
mMonthlyRate = inMonthlyRate
End If
End Set
End Property
Public Property Quantity() As Integer
Get
Return mQuantity
End Get
Set(ByVal inQuantity As Integer)
If inQuantity > 0 Then
mQuantity = inQuantity
End If
End Set
End Property
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|