Everything above this quote is correct:
Let's talk about this part:
The word "instantiate" is the weird one there. Let's talk about it.
If you declare a variable without assigning it a value, it doesn't have a value. For classes, that means it will hold the value "Nothing". Sort of. So if you wrote this line in the Main module, then 'basket' would be Nothing:
Code:
Friend basket As GroceryBasket
See how that
doesn't have the New keyword? If you don't use New, you aren't creating anything.
To actually create a GroceryBasket, you have to use the New Keyword. The long way to write that out would look like:
Code:
Friend basket As GroceryBasket = New GroceryBasket()
This is tedious, and we very often want to instantiate at the same time we create a variable, so you can take a shortcut:
Code:
Friend basket As New GroceryBasket()
To really get the sense of it, think about a 3D printer. Let's say I want to print a cute little bunny statue. I can load the file that represents the bunny statue into a program. That's "declaring the variable":
Code:
Dim statue As BunnyStatue
But I don't have a statue yet. I have to push the button to send the "blueprints" to the printer so it can print the statue for me. That's what 'New BunnyStatue()' does:
Code:
Dim statue As New BunnyStatue()
"Instantiate" is the fancy word we made up for "create".
So that quote from above seems kind of silly in context:
It's already instantiated in the module, so I don't know why they want you to do it again. But you may as well follow the instructions. Since the variable already exists, you don't have to declare it. So under the End If in your Sub, I'd write:
Code:
Main.basket = New GroceryBasket()
----1------ --------2----------
The part I've underlined as (1) says, "this is the variable I'd like to change". Since 'basket' belongs to the module 'main', its name is 'Main.basket'. The part I've underlined as (2) says, "Instantiate a new GroceryBasket". The = sign tells VB, "Assign the thing on the right to the variable on the left."
Now, the next part:
Since GroceryBasket is a List(Of GroceryItem), you can use its Add() method to add a grocery item to it. That means you need to instantiate at least one GroceryItem and give it to the Add() method. It might look like this:
Code:
Dim apple As New GroceryItem(1, "Apple Acres", 0.25)
Main.basket.Add(apple)
The first line instantiates a new GroceryItem and stores it in a variable named 'apple'. The next line adds that object to the basket. You could do this all on one line:
Code:
Main.basket.Add(New GroceryItem(1, "Apple Acres", 0.25))
But note how that is a little less clear. Sometimes saving space doesn't help us!
The assignment's asking you to get used to that, but:
It seems that part was optional.