[英]How to edit user input on java?
I am currently making a voting system where the voter enters in their details such as name, age etc. I also have another class for admin, the admin can view the list of results but i also want the admin to edit the voter details and to save the edit. 我目前正在制作一个投票系统,投票人在其中输入他们的详细信息,例如姓名,年龄等。我还有另一个用于管理的类,管理员可以查看结果列表,但我也希望管理员编辑投票人的详细信息并保存修改。 this is what i have so far: 这是我到目前为止所拥有的:
public void EditVoterAccounts()
{
int i=0;
for (Voters vote: Voters.listVoters)
{
System.out.println(i + " " + vote.getName());
}
}
Also another problem is the list of the voters come up as all 0. For example, it should show up like this: 另外一个问题是选民名单全为0。例如,它应显示为:
0 voter
1 second voter
3 third.
but what I am getting is this: 但是我得到的是:
0 voter
0 second voter
0 third
which I am guessing will confuse the system 我猜这会使系统混乱
You've forgotten to increment the counter. 您忘记了增加计数器。
public void EditVoterAccounts()
{
int i = 0;
for (Voters vote: Voters.listVoters)
{
System.out.println(i + " " + vote.getName());
i++;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.