Skip to content

Instantly share code, notes, and snippets.

@steppat
Created March 17, 2022 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steppat/a93416ea99d41b20894914cd74558a93 to your computer and use it in GitHub Desktop.
Save steppat/a93416ea99d41b20894914cd74558a93 to your computer and use it in GitHub Desktop.
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