gpt4 book ai didi

java - 比较排行榜表上前几行的值,简单查询

转载 作者:行者123 更新时间:2023-11-28 20:50:13 26 4
gpt4 key购买 nike

我正在尝试比较前一行的选择状态,以确保选择状态高于前一行。用户进行 4 次选择,如果选择状态为 1 或 2,则将其添加到选择状态总数中。

won_and_looking_good 总计最高的用户在表格中名列前茅,但如果用户总计相同,则考虑他们的 points_player。

我基本上是在尝试将 total_of_won_and_looking_good 与上一行的 total_of_won_and_looking_good 进行比较,我似乎可以弄清楚该怎么做。这是我的代码:

test_player_leaderboard_entry() {

    int previous_total = 0;

int size = playerRows.size();


for (int i = 0; i < size; i++) {

//Position
String position_first_player = Drivers.getDriver().findElement(By.cssSelector("[data-qa-position-value='" + i + "']")).getText();
//Points
String points_player = Drivers.getDriver().findElement(By.cssSelector("[data-qa-points-value='" + i + "']")).getText();
//Username
String username_player = Drivers.getDriver().findElement(By.cssSelector("[data-qa-player-value='" + i + "']")).getText();
//Row Number
Integer row = i + 1;
Integer total_of_won_and_looking_good = 0;
//PICKS
for (int pick_number = 1; pick_number < 5; pick_number++) {
String pick_status = Drivers.getDriver().findElement(By.xpath("//*[@id='root']/div/main/section[2]/section/div/ol/a[" + row + "]/li/div[3]/div[" + pick_number + "]/div")).getAttribute("data-qa-pick-state");
//System.out.println(pick_status);
if (Integer.parseInt(pick_status) == 2 || Integer.parseInt(pick_status) == 1) {
total_of_won_and_looking_good = total_of_won_and_looking_good + 1;

}
}if (i > 0 && total_of_won_and_looking_good >= previous_total) {
System.out.println("Pick amounts are the same");

}

System.out.println("On row number " + row + " we find " + username_player + " in position " + position_first_player + " with " + total_of_won_and_looking_good + " correct picks and " + points_player + " points!");
}
}

最佳答案

所以你想测试 total_of_won_and_looking_good 单调递减。

你需要记录之前的值,如果你不在第一行,将新值与之前的值进行比较。

你需要一个新的局部变量:int previous_total;test_player_leaderboard_entry 主体的第一行声明。在你计算出新的值(value)之后,像这样:

if (i > 0 && total_of_won_and_looking_good > previous_total) {
// report the error
}
previous_total = total_of_won_and_looking_good;

就在您当前的 System.out.println 之前。

关于java - 比较排行榜表上前几行的值,简单查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49981820/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com