Consume the PokéAPI (Pokémon API) utilizing just C# language, list the Pokémons and allows the user to choose a Pokémon for "adoption".
C# Language
.NET Framework
PokéAPI
Json
- Create C# code to execute the HTTP GET request.
- Catch the Json from the request.
- Print the Json on the console.
Using just the library System.Net
was made a request to the PokéAPI and cached the list of Pokémons Json:
- Parse the Json response and extract each Pokémon info.
- Show the organized information on the console.
The Json was parsed with the System.Text.Json.JsonSerializer
class and the class Pokemon
was created to represent a Pokémon entity.
- Create an interactive menu and allow user to view your current mascots, choose an mascot to adopt and exit the app.
Was created the class App
where resides the application interactive menu, and the class PokemonRepository
responsible for getting from cache/PokeAPI and saving the mascots.
- Organize the project source files in the MVC (Model View Controller) standard.
The application was divided into classes according to MVC:
Model: Ability
, Mascot
, Pokemon
View: AppView
Controller: AppController
- Add common mascot attributes hungry, sleepy, happiness, tiredness, health.
- Add mascot actions eat, sleep, play.
- Create Mascot class.
- Map Pokemon class to Mascot class.
Was created the class Mascot
that inherit from Pokemon and implements common mascots attributes and actions.
- Build and generate the executable of the application.
The application was published with the dotnet publish
command.