编辑对象/ Java中的ArrayList连连 [英] edit object/arrayList in java again and again
问题描述
我已经整理AllayList使用对象是指我的previous后<一个href=\"http://stackoverflow.com/questions/24026343/how-to-sort-and-get-highest-value-from-java-object-\">How进行排序,并从Java对象最高值/ ArrayList的
I have sorted AllayList with Objects refer to my previous post How to sort and get highest value from Java Object/ArrayList
ArrayList<> allStudents = new ArrayList();
allStudents.add(new Student("H", 99, 93) );
allStudents.add(new Student("C", 98, 92) );
allStudents.add(new Student("B", 98, 91) );
allStudents.add(new Student("A", 80, 94) );
allStudents.add(new Student("F", 70, 84) );
现在在
步骤1:我想任何人都取(随机选择任何对象),否则他们的第一个最高的(即H),然后编辑号码然后保存回来。
第二步:我想获取任何人(随机选择任何对象),他们还有第二高的(即C),然后编辑号码然后保存回来。
第三步:我要获取它们的其他任何人(随机选择任何对象)居第三位(即B),然后编辑号码然后将其保存回
Now in step1: I want to fetch anyone (randomly select any object) of them else the first highest(that is "H"), then edit numbers then save it back. step2: I want to to fetch anyone (randomly select any object) of them else the second highest(that is "C"), then edit numbers then save it back. step3:I want to to fetch anyone (randomly select any object) of them else the third highest(that is "B"), then edit numbers then save it back.
在所有5将完成,那么这个过程将再次从第一步开始。通过这种方式,我可以减少所有学生的人数。
When all 5 will be finished, then the process will start again from step1. In this way I can reduce all student's numbers.
如果有人请建议我我该怎么办呢?
If someone please suggest me how can I do that?
推荐答案
我得到了答案BU做一些简单的算术。创建另一个类来选择波纹管的情况下随机数:
I got the answer bu doing some simple arithmetic. Create another class to select random number for bellow cases:
第一步:以当前的学生指数
第二步:随机选取一名学生,其中数字应该减少,而不是第一步的学生
step1: Taking current student index step2: Randomly selecting one student, whom number should reduce, rather than step1 student
继续再次第一步和第二步
continuing again step1 and step2
这篇关于编辑对象/ Java中的ArrayList连连的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!