#Java

1 messages · Page 1 of 1 (latest)

lost wingBOT
#

<@&987246399047479336> please have a look, thanks.

celest rivet
#

Where are you stuck? As it stands we have your assignment.

high anchor
#
    public static void updateScore(int teamNumber, int points) {
        switch (teamNumber) {
            case 11: seliparWarriors += points; break;
            case 21: slipStrike += points; break;
            case 45: flipFlopFighters += points; break;
            case 66: slipperSnipers += points; break;
            case 7: throwLuckySeven += points; break;
            case 34: seliparSlayers += points; break;
        }
    }

    public static void displayScores() {
        System.out.println("SeliparWarriors: " + seliparWarriors);
        System.out.println("SlipStrike: " + slipStrike);
        System.out.println("FlipFlopFighters: " + flipFlopFighters);
        System.out.println("SlipperSnipers: " + slipperSnipers);
        System.out.println("ThrowLuckySeven: " + throwLuckySeven);
        System.out.println("SeliparSlayers: " + seliparSlayers);
    }
lost wingBOT
high anchor
#

but how to determine the winner in another method determineWinner? write one by one if-else?

celest rivet
#

You'd use some kind of loop to dermine which team in the list has the highest number, you don't want to add another else whenever a new team gets added.

high anchor
#

but if I want to execute for loop, then have to use array, am I right?

celest rivet
#

A basic for, a while, an enhanced for, a stream, etc..
And yes, I'd store the list of teams in a list.

high anchor
#

Java

lost wingBOT
#

Closed the thread.