Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop a Visual C# .NET solution that provides a login validation service. This solution will have a class library component and two application components contained

Develop a Visual C# .NET solution that provides a login validation service. This solution will have a class library component and two application components contained within the same solution.

The LoginValidator Class

Create a class library project named LibLoginValidator that contains a class named LoginValidator. The LoginValidator class must support the following features:

  • The class defines a public string read/write property named Username which gets/sets the Username for the validator.
  • The class defines a public string property named Password which sets the Password for the validator. The get part should be private.
  • The constructor for the class should set the initial values of Username and Password to null.
  • The class defines a public method named Authorize with no parameters which returns a bool? (nullable bool) value.
    • If either Username or Password is null, the method should return null to indicate that not all fields were provided.
    • If both Username and Password are not null, then the method should compare the username and password against 3 hardcoded sets of values in the method. Be sure to include one where the username is wayne and the password is bryan (all lowercase). If a hardcoded username/password pair is found, the method returns true. Otherwise the method returns false.

The Console Application

Create a console application that asks the user to enter a username and password. The application will then pass the username and password to an instance of the LoginValidator. If the username or password is empty string, the application must pass null to the validator instead (for whichever one is empty string). Note that you can test for empty string by checking for a 0 length or comparing with "" or string.Empty.

The application should then call the LoginValidator object's Authorize method. If the returned value is null, the application must give a message stating that both username and password are required. If the returned value is false, the application must display a message stating that the authorization has failed. Otherwise the application should state that the authorization was successful and allow the user to press any key to exit. The code should be included inside a loop so that the user is prompted to enter the username and password again if the authorization is unsuccessful.

The Windows Application

Create a Windows Forms application. The form window for the application appears as shown. Use proper names for the project, the form, and the controls and give your form a title. Notice the shortcut keys for Username and Password text boxes. The Login button should be set as the form's AcceptButton (see the form's AcceptButton property). The application must create an instance of the LoginValidator in a private class field of the form.

When the user types in the username text box, the application assigns the text to the LoginValidator object's Username property. If the text box is empty, the application assigns null instead.

When the user types in the password text box, the application assigns the text to the LoginValidator object's Password property. If the text box is empty, the application assigns null instead.

When the user clicks the Login button, the application calls the LoginValidator object's Authorize method. If the returned value is null, the application shows an ERROR message box stating that the username and password must be provided. If the returned value is false, the application shows a WARNING message box stating that the authorization was not successful and then clears the username and password text boxes and put the focus back in the username text box. Otherwise the application shows an INFORMATION message box stating that the authorization was successful and then closes the form.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

More Books

Students also viewed these Databases questions