|
-
Jan 26th, 2018, 03:49 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Properties, Enumeration, & Constructors
Im doing step by step..My instructions are:
The GroceryItem class should contain the following public properties:
1. ScanNumber - Represents the unique serial code for the item on the shelf. This property should be read-only.
2. BrandName - The name as described on the item’s packaging
3. Description - A short description of the item
4. Price - The amount of money it costs to buy the item. Make sure that only positive values can be assigned to this property.
5. Aisle - This should indicate one of the following aisles: Bakery, CannedGoods, Drinks, Deli, DryGoods, FrozenFoods, and Produce.
This is my Grocery Item code:
Code:
Public Class GroceryItem
Public ReadOnly Property ScanNumber As Integer
Get
Return ScanNumber
End Get
End Property
Public Property BrandName As String
Get
Return BrandName
End Get
Set (value As String)
BrandName = value
End Set
End Property
Public Property Description As String
Get
Return Description
End Get
Set (value As String)
Description = value
End Set
End Property
Public Property Price As Integer
Get
Return Price
End Get
Set (value As Integer)
Price = value
End Set
End Property
Public Property Aisle As String
Get
Return Aisle As String
End Get
Set (value As String)
Aisle = value
End Set
End Property
End Class
It says you can use enumeration.
The GroceryItem class should contain the following public constructors:
1. A constructor that accepts and sets only the ScanNumber property. Remember: If a property is read-only, then you’ll need to set the variable, not use the property name.
2. A constructor that accepts and sets the ScanNumber, BrandName and Price properties.
Add a new public class named GroceryBasket to the project.
1. Derive from the generic List class.
2. Ensure that only GroceryItem objects are stored as items.
Add the following variable declaration to the Main module: Friend basket As New GroceryBasket
My Main Code:
Code:
Module Main
Friend blnLoggedIn As Boolean
Dim arrUsernames() As String = {"Admin", "Clerk", "Manager"}
Dim arrPasswords() As String = {"P@ssword", "pa$$word", "passw0rd"}
Dim userIndex As Integer
Friend basket As New GroceryBasket
Test your work.
Note: You can add code to the btnLogin_Click event handler procedure to instantiate the GroceryItem class and add multiple objects to the GroceryBasket variable. Make sure you either remove or comment out this code after testing.
Last edited by EmilyM1105; Jan 27th, 2018 at 04:36 AM.
Tags for this Thread
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
|