lundi 30 avril 2018

I want to use getters and setters for a game table

Hi Im trying to set up a person class for each player on a leaderboard, since i dont know how long the leader board is im going to try and loop the amount of people by the count of the rows in the leaderboard. Then im trying to "get" the points for each row and compare each one again the previous to assert the higher number is one the top, ive never used getters and setters before and cant seem to figure out how to do this, any help??

Here is the code for the information i want for each person, I need to find the player_picks, position and player_points . I then need to compare the count of each player_picks total with each player as i go down the leaderboard. If the pick_total is is equal i then need to compare their points total.Ive been trying this for a few weeks but someone suggested it would be easier making a player class and then using get and setters to assign attributes to each of them. SO i could then compare player1 with player 2, player 2 and player 3 etc. Whats making mit difficult is that i dont know the size of the list each time so its confusing me.

Below is the code im using which gives me the attributes im look to "set" but i dont know how to set up a "people" in a person class as the amount of people required each time with be changing (using int size) as a different amount of people join each game.

Im new to this so if im not explaining this well let me know.

public void test_player_leaderboard_entry() {

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;

        }
        //System.out.println(total_of_won_and_looking_good);
    }

    //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!");
}

}

Aucun commentaire:

Enregistrer un commentaire