Penn Foster 037849 – Grocery app, Grocery item class with screenshots – Perfect Solution – Instant Delivery
OBJECT-ORIENTED PROGRAMMING FUNDAMENTALS
You now have the requisite OOP knowledge to expand the logic in the GroceryApp project. This project will assess your ability to create and use classes, collections, enu¬merations, and runtime exceptions. Make sure that you follow all directions completely and verify your results before submitting the project. Remember to include all required components in your solution.
Note: The output of this project will be used in the graded project for Lesson 4.
In the graded project for Lesson 2, you implemented the login process for a Windows Forms application in Visual Studio. In this project, you’ll add exception handling to that login process. You’ll also create a class to represent a grocery item and a custom collec¬tion class to represent a grocery basket.
1. In Visual Studio, load the GroceryApp project that you completed in Lesson 2.
2. Add a new class named LoginException to the project.
3. Make the LoginException class a custom exception by deriving from the Exception class. See section 3.2 for an example.
4. In the Login procedure of the Main module, replace the two lines that read MessageBox.Show (“Incorrect password.”) with the following code:
Throw New LoginException
5. Save your work and debug the application. What happens now when you type in an incorrect password for a valid username?
6. Stop debugging the application. You’ll now add exception handling code.
7. Add a Try…Catch statement for the following line in the btnLogin_Click event handler procedure:
8. Add the following line to the Catch block:
9. Save your work and debug the application. It should perform the same action as before.
10. Add a new public class to the project, named GroceryItem.
11. The GroceryItem class should contain the following public properties:
Q QScanNumber—Represents the unique serial code for the item on the shelf. This property should be read-only.
Q QBrandName—The name as described on the item’s packaging
Q QDescription—A short description of the item
Q QPrice—The amount of money it costs to buy the item. Make sure that only positive values can be assigned to this property.
Q QAisle—This should indicate one of the following aisles: Bakery, CannedGoods, Drinks, Deli, DryGoods, FrozenFoods, Produce.
See section 3.4 for how to create an enumeration.
The GroceryItem class should contain the following public constructors:
Q QA 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.
Q QA constructor that accepts and sets the ScanNumber, BrandName, and Price properties
13. Add a new public class named GroceryBasket to the project.
Q QDerive from the generic List class.
Q QEnsure that only GroceryItem objects are stored as items.
14. Add the following variable declaration to the Main module:
Friend basket As New GroceryBasket
15. Test your work.
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.
Remember to follow directions and good OOP principles as described in Lesson 3.
Your project will be graded using the following rubric:
Exemplary (4) Proficient (3) Fair (2) Poor (1) Not Evident (0)
The LoginException class is defined correctly. The LoginException class is defined somewhat correctly. The LoginException class is defined mostly correctly. The LoginException class is defined poorly. There’s no evi-dence of the LoginException class.
The Login button correctly uses a Try…Catch statement. N/A N/A N/A The Login button incorrectly uses a Try…Catch statement.
The GroceryItem class is defined correctly. The GroceryItem class is defined mostly correctly. The GroceryItem class is defined somewhat correctly. The GroceryItem class is defined poorly. There’s no evi-dence of the GroceryItem class.
The GroceryBasket class is defined correctly. The GroceryBasket class is defined mostly correctly. The GroceryBasket class is defined somewhat correctly. The GroceryBasket class is defined poorly. There’s no evi-dence of the GroceryBasket class.
All source code files are included. Most source code files are included. Some source code files are included. Few source code files are included. There’s no evi-dence of code files.
To find these files, you should go to the directory where you saved the GroceryApp proj¬ect. To open the project directory, right-click GroceryApp in the Solution Explorer panel and choose the Open Folder in File Explorer option in the context menu.
Copy the Main.vb, LoginForm.vb, LoginException.vb, GroceryItem.vb, and GroceryBasket.vb files to your desktop or any other temporary location.
Each project is individually graded by your instructor and therefore takes up to a few weeks to grade.
To submit your graded project, follow these steps:
1. Go to http://www.pennfoster.edu.
2. Log in to your student portal.
3. Click Take Exam next to the lesson you’re working on.
4. Follow the instructions provided to complete your exam.
Be sure to keep a backup copy of any files you submit to the school!
Any personal information received will only be used to fill your order. We will not sell or redistribute your information to anyone.
We will try our best to resolve the issue and if still persists we can discuss for a refund in case its required.