Get Solved Penn Foster 037841
Object-Oriented
Programming
Fundamentals
OVERVIEW
YOUR PROJECT
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 the login
process. You’ll also create a class to represent a grocery item
and a custom collection class to represent a grocery basket.
The output of this project will be used in the next graded
project.
INSTRUCTIONS
1. In Visual Studio, load the GroceryApp project that you
completed in Lesson 2. If this isn’t available, then you’ll
need to ask your instructor for the finished Lesson 2
project.
2. Add a new class to the project named LoginException.vb
(Figure 34).
Make the LoginException class a custom exception by
deriving from the Exception class. See Assignment 3 for
an example.
3. 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
4. Save your work and debug the application. What happens
now when you type in an incorrect password for a
valid username?
5. Stop debugging the application. You’ll now add an exception
handling code.
6. Add a Try…Catch statement for the following line in the
btnLogin_Click event handler procedure:
Main.Login(text username.Text, txtPassword.Text)
Add the following line to the Catch block:
MessageBox.Show(“Incorrect password.”)
FIGURE 34—Enter LoginException.vb and click Enter.
7. Save your work and debug the application. It should
perform the same action as before.
8. Add a new public class to the project named
grocery items. See Assignment 1 for help.
9. The class should contain the following public properties:
■ ScanNumber. Represents the unique serial code for
the item on the shelf. This property should be read only.
■ BrandName. The name as described on the item’s
packaging
■ Description. A short description of the item
■ Price. The amount of money it costs to buy the item.
Make sure that only positive values can be assigned
to this property.
■ Aisle. This should indicate one of the following
aisles: Bakery, Canned Goods, Drinks, Deli,
Dry Goods, Frozen Food, and Produce. See
Assignment 2 on how to create enumerations.
10. The class should contain the following public
constructors:
■ 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.
■ A constructor that accepts and sets the
ScanNumber, BrandName, and Price properties.
11. Add a new public class to the project named
GroceryBasket. See Assignment 2 for help.
a. Derive from the generic Dictionary class.
b. Ensure that only String values are used as keys.
c. Ensure that only GroceryItem objects are stored as
values.
12. 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
class. Make sure you either remove or comment on this
code after testing.
SUBMISSION GUIDELINES
To submit your project, you must provide the following five
files:
■ Main. vb
■ LoginForm.vb
■ LoginException.vb
■ GroceryItem.vb
■ GroceryBasket.vb
Want Help with Penn Foster?
Are you a struggling pupil who isn’t able to handle the strain he is dealing with withinside the case of taking the internet tests due to numerous extraordinary activities? Or are you finding it very complicated to finish the given tests at once with some top-notch grades? Don’t worry, Examshelpers help you in this situation! The IWantOnlineclasshelp.com company enterprise is the terrific top-notch service you can avail of in recent times for the betterment of your future and the suitable affiliation of premium-level of test-taking services on your behalf. We have been constantly providing super help to every & every pupil who turned searching out affordable, reliable, and qualitative services in a well-timed manner. Whether it ways about exam problems or exam-related problems, you are facing, we’re capable of covering in the course of paying a person to take my online exam services on the go. The Online Test Help query is solved properly right here quickly. Just call us or mail us, and we may be there to hold some professional top-notch exam-taking services with a money-once-more guarantee, consequently, you will do not have anything to drop. Pay to do a web exam now. For custom, help email us at [email protected] or WhatsApp us at +1(657)366-7486