Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
3.21/5 (8 votes)
See more:
Hi, I'm creating a fictional online banking program for 10 fictional clients using C#. I have already created the Usernames for each client as well as creating a password restriction policy.

Ideally the program should run:

Please enter your username: Johnbanks
Client John Smith please enter your password: eASY-toHac
From your memorable data please enter character 3: e
From your memorable data please enter character 6: 7
From your memorable data please enter character 8: w
Successful login of client John Smith

I need some help creating a piece of code that will request 3 characters which are always requested in numeric order i.e it would ask for 1, 4 & 7 and never 4, 1 & 7

Has anyone created a program like this? and if so could they offer me some guidance on how I should correctly layout the code.
Thanks,
Niall
Posted
Updated 29-Oct-14 14:43pm
v2
Comments
Sergey Alexandrovich Kryukov 29-Oct-14 19:59pm    
How to classify it: off-topic or not a question? "Has any one has created a program like this?" is a question, but not on the topic of our forum. What kind of answer can help you? Yes, many create something like that. So what, is it really helpful?
—SA
nizey07 29-Oct-14 20:25pm    
What I meant was, has anyone created a similar program to the banking login validation program which I am trying to create? and if so would they be able to offer me some guidance in how to correctly layout the code.
Niall
Sergey Alexandrovich Kryukov 29-Oct-14 20:38pm    
Why would you be interested to know that? How knowing that anyone did anything like that? The whole idea is really horrible. How can this trick help anything?
And why do you think that a person who did something like that could help. It's just the opposite: more likely the person who never did that will help you.
You probably have a very perverted idea of experience, help and engineering. It's like looking for a car driving instructor who is able to help you to learn driving your car, by trying to find only the one who used to drive red Toyota Corolla E140, 4V, 4-door of 2008 exactly.
—SA
nizey07 29-Oct-14 20:49pm    
What are you talking about? this is my first program that I am trying to write. I've only been studying C# for a few weeks and as it is mid term I can't speak with anyone in my class for guidance. I was only asking for some advice there's no need to berate me for being new to this area of study, I'm sure you were a beginner at some stage.
Sergey Alexandrovich Kryukov 29-Oct-14 23:42pm    
Nobody tells you that you cannot ask. But you are not asking for help, you are asking for someone who did the same. Why? This is wrong. If you have a question on technology, ask it. But the idea is very weird. Why doing this 6th, 3rd character game? Why?
—SA

1 solution

Well, the obvious solution would be to just generate three unique numbers up front and then sort them. To get started, you're going to want a random number generator that generates a number between 0 and 9 - note that the .NET random number generator is only pseudo-random; if you want it to generate a unique combination whenever you start it up, use a seed value (these are all keywords you can search in google for).

Okay, once you have a number, you want to ensure that you haven't already added it into your list. As you're only generating three numbers, storing your values in a SortedSet will be a decent option as checking to see if you have already added it will not take any significant time - and it will give you that sort out of the box.

Please don't let negative comments put you off CodeProject. You didn't ask a bad question, in my opinion, so I'm more than happy to help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900