Created
March 17, 2022 23:46
-
-
Save steppat/a93416ea99d41b20894914cd74558a93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SevenDaysOfCodeJavaDay7 { | |
public static void main(String[] args) throws Exception { | |
System.out.println("Chamando API"); | |
String apiKey = "____"; | |
List<? extends Content> content = new ImdbApiClient(apiKey).extract(); | |
// String apiKey = "___"; | |
// String privateKey = "____"; | |
// List<? extends Content> content = new MarvelApiClient(apiKey, privateKey).extract(); | |
Collections.sort(content, Collections.reverseOrder()); | |
System.out.println("Gerando HTML"); | |
PrintWriter writer = new PrintWriter("ranking.html"); | |
new HtmlGenerator(writer).generate(content); | |
writer.close(); | |
} | |
} | |
interface Content extends Comparable<Content> { | |
String title(); | |
String urlImage(); | |
String rating(); | |
String year(); | |
} | |
record Movie(String title, String urlImage, String rating, String year) implements Content{ | |
@Override | |
public int compareTo(Content content) { | |
Integer selfYear = Integer.valueOf(this.year()); | |
Integer otherYear = Integer.valueOf(content.year()); | |
return selfYear.compareTo(otherYear); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment