Skip to content

Commit

Permalink
Improvements on days 27 and 28
Browse files Browse the repository at this point in the history
Signed-off-by: hbelmiro <helber.belmiro@gmail.com>
  • Loading branch information
hbelmiro committed Mar 10, 2022
1 parent 2c9a567 commit 0c9da3d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void main(String[] args) {

private static List<Player> createList() {
var messi = new Player("Lionel Messi", "PSG", "Argentina", 42);
var cr7 = new Player("Cristiano Ronaldo", "Juventus", "Portugal", 50);
var cr7 = new Player("Cristiano Ronaldo", "Manchester United", "Portugal", 50);
var lukaku = new Player("Romelu Lukaku", "Chelsea", "Belgium", 41);

return List.of(messi, cr7, lukaku);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
package com.thegreatapi.ahundreddaysofjava.day028;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class Day028 {
import static java.util.Comparator.comparing;

public final class Day028 {

public static void main(String[] args) {
Player messi = new Player("Lionel Messi", "Barcelona", "Argentina", 42);
Player cr7 = new Player("Cristiano Ronaldo", "Juventus", "Portugal", 50);
Player neymar = new Player("Neymar Jr.", "PSG", "Brazil", 41);
var messi = new Player("Lionel Messi", "PSG", "Argentina", 42);
var cr7 = new Player("Cristiano Ronaldo", "Manchester United", "Portugal", 50);
var lukaku = new Player("Romelu Lukaku", "Chelsea", "Belgium", 41);

List<Player> players = Arrays.asList(messi, cr7, neymar);
List<Player> players = Arrays.asList(messi, cr7, lukaku);

players.sort(Comparator.comparing(Player::numberOfGoals).reversed());
players.sort(comparing(Player::numberOfGoals).reversed());

System.out.println("Top Scorers:");
players.forEach(System.out::println);
}

private record Player(String name, String club, String coutry, int numberOfGoals) {
private record Player(String name, String club, String country, int numberOfGoals) {
}
}

0 comments on commit 0c9da3d

Please sign in to comment.