7DaysOfCode.io is a webpage maintained by Alura — a Brazilian Technology School — with a set of code challenges divided by technology (languages, frameworks, tools, etc.) so the students can put in practice their knowledge solving 7 challenges, one per day, in the technology they're learning.
This repository is for the Java challenges. Learn more and subscribe at https://7daysofcode.io/matricula/java
On the first day, you will make your Java code consume the IMDB API, fetch the top 250 movies from their list and print the corresponding JSON in the console.
On that day, you will parse the JSON response you get from IMDB to extract its information and attributes (such as title, poster, rating, etc).
As and extra, I decided to cache the API response in order to save resources and avoid being blocked by IMDB server due to too many requests. Certainly there are better ways to do that... but I developed my own solution, and I'm proud of it :-)
In today's challenge, the idea will be to model, or at least start modeling your code better. A Movie
should have the
following attributes: title
, urlImage
, rating
and year
.
Also, instead of having several lists (one for each movie attribute), it's much better to organize this into a
single List<Movie>
, where each movie encapsulates its own data.
In the day four you're going to generate an HTML page from the list of objects you already have in your Java code. The HTML page will have the information about the movie, including the poster, something like:
— See this page at https://afonsodemori.github.io/sevendays-java/day-4-movies.html
Today's challenges are:
- Encapsulating the API call inside a new class. You can call this class
ImdbApiClient
. - Also, to improve encapsulation and separate all responsibilities into their proper classes, create a new class to parse the JSON.
- Alura: What is encapsulation? (in portuguese)
Adapt your code to also work with Marvel API. You should make your code more generic and prepared to receive data from other APIs. For this, interfaces come into play, which allow different implementations.
— See this page at https://afonsodemori.github.io/sevendays-java/day-6-comics.html