Can someone tell me if Im on the right track and what Im missing??
My instructions are:
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.
Here is my GroceryBasket Code:
Did I write that right?? If not how do I??Code:Public Class GroceryBasket Inherits List(Of GroceryItem) End Clas
Heres my GroceryItem Code:
Code:Public Class GroceryItem Private mScanNumber As Integer Public ReadOnly Property ScanNumber As Integer Get Return mScanNumber End Get End Property Private mBrandName As String Public Property BrandName As String Get Return mBrandName End Get Set(value As String) mBrandName = value End Set End Property Private mDescription As String Public Property Description As String Get Return mDescription End Get Set(value As String) mDescription = value End Set End Property Private mPrice As Double Public Property Price As Double Get Return mPrice End Get Set(value As Double) If value > 0 Then mPrice = value End If End Set End Property Private mAisle As String Public Property Aisle As String Get Return mAisle End Get Set(value As String) mAisle = value End Set End Property Public Sub New(MscanNumber As Integer, brandName As String, price As Double) Me.mScanNumber = ScanNumber Me.BrandName = brandName Me.Price = price End Sub End Class
I already did this part: Add the following variable declaration to the Main module: Friend basket As New GroceryBasket
Heres 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
I dont understand how to do this part either??
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.
Here is my LoginForm with the btnlogin_Click handler:
Code:Public Class LoginForm Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click Try Login(txtUsername.Text, txtPassword.Text) Catch ex As LoginException MessageBox.Show(“Incorrect password.”) End Try If Main.blnLoggedIn Then MessageBox.Show(“Thank you for logging in, “ & txtUsername.Text, “Logged In.”) Me.Close() End If End Sub Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click Application.Exit() End Sub End Class




Reply With Quote
