Open your existing GameConsole application Validation.cs Create a new method to validate user input against a dynamic
Fantastic news! We've Found the answer you've been seeking!
Question:
Open your existingGameConsoleapplication
Validation.cs
- Create a new method to validate user input against a dynamic list of approved answers. Note: Think of this like drop-down menu on a website form. Ex: when asking for a month, there are only 12 acceptable responses, anything else is invalid.
Users.txt
- Create a text document to hold user information:username,password,age, andtheme
- Pre-populate this with a few users (3+)
User.cs
- Create a login method, belonging to the class, not a particular object... This should return an instantiated object based on a successful comparison to the users.txt file Note: Think of this like a bouncer or host at a fancy restaurant. You walk up and give them your name.... try breaking it down step-by-step, how does the host know if you are allowed in. They have a file containing reservations, and you have a text-file containing registered users.
- Add another method allowing for the saving of new users. Use the newly created validation method to validate the user inputed theme... lightanddark are the only current themes.
Program.cs
- Instead of simply instantiating a user object with hard-coded values, use the login method to set the current user.
- If necessary, the store logged-in user so that it's accessible within other classes. We want to prevent the user from having to login each time they are returned to the 'home screen'.
Related Book For
Principles Of Information Security
ISBN: 9780357506431
7th Edition
Authors: Michael E. Whitman, Herbert J. Mattord
Posted Date: