虚构的在线银行计划 [英] Fictional online bank program
问题描述
我正在为使用C#的10个虚构客户创建一个虚构的网上银行计划。我已经为每个客户创建了用户名以及创建密码限制策略。
理想情况下该程序应该运行:
请输入您的用户名:Johnbanks
客户John Smith请输入您的密码:eASY-toHac
从您难忘的数据中输入字符3:e
从您难忘的数据中输入字符6:7
从您难忘的数据中输入字符8:w
成功登录客户John Smith
我需要一些帮助来创建一段代码,它将要求3个字符,这些字符总是以数字顺序请求,即它会要求1,4和7而不是4, 1&7
有没有人创建过这样的程序?如果是这样,他们可以就如何正确布局代码提供一些指导。
谢谢,
Niall
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
推荐答案
嗯,显而易见的解决办法就是生成三个唯一的数字前面然后对它们进行排序。首先,您将需要一个生成0到9之间的数字的随机数生成器 - 请注意,.NET随机数生成器只是伪随机数;如果你希望它在你启动时生成一个独特的组合,使用种子值(这些都是你可以在谷歌搜索的关键词)。
好的,一旦有号码,您需要确保尚未将其添加到列表中。因为你只生成三个数字,所以将你的值存储在SortedSet中将是一个不错的选择,因为检查你是否已经添加它不会花费任何重要的时间 - 并且它将为你提供开箱即用的数据。 br />
请不要让负面评论让你离开CodeProject。在我看来,你没有问过一个糟糕的问题,所以我非常乐意提供帮助。
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.
这篇关于虚构的在线银行计划的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!