A C# application to explore and display Star Wars planets' statistics, showcasing LINQ, Generics, and ASCII table printing! 🚀
- Introduction
- Features
- Technologies
- Installation
- Usage
- Data Source
- Optional: Universal Table Printer
- Contributing
- License
The Star Wars Planets Stats is a C# project developed as part of the Ultimate C# Masterclass assignment. This application retrieves and processes planetary data from the Star Wars universe, presenting it in a clean, tabular format. Originally designed to use the SWAPI (Star Wars API), it now leverages a mock data provider (MockStarWarsApiDataReader) due to the API's unavailability. The project showcases advanced C# features like LINQ, Generics, and ASCII table printing, making it both educational and fun for developers and Star Wars fans alike! ✨
- 🌍 Retrieve and display Star Wars planets' statistics
- ✅ Process data using LINQ queries for filtering and sorting
- 📊 Print planet data in a customizable ASCII table
- 🔧 Use Generics for a flexible, reusable table printer
- 🛠️ Robust fallback to mock data when the external API is unavailable
This project highlights the following C# technologies:
- LINQ: For querying and manipulating planet data efficiently.
- Generics: To create a universal table printer that works with any object type.
- ASCII: For rendering clean, tabular output in the console.
- API Integration: Designed to work with the SWAPI (with a mock fallback).
To get started with Star Wars Planets Stats, follow these steps:
- Clone the repository:
git clone https://github.com/username/star-wars-planets-stats.git
- Navigate to the project directory:
cd star-wars-planets-stats - Restore dependencies: Ensure you have the .NET SDK installed, then run:
dotnet restore
- Build the project:
dotnet build
Prerequisites:
- .NET SDK (version 6.0 or higher)
- A C# IDE (e.g., Visual Studio, VS Code, or Rider)
Run the application to explore Star Wars planets' statistics:
dotnet runExample usage:
- Display all planets in a tabular format with properties like Name, Diameter, and Population.
- Use LINQ to filter planets (e.g., by climate or terrain).
- Customize the table output using the universal table printer.
For detailed code examples, check the src/ directory.
MockStarWarsApiDataReader namespace as an alternative data source. The mock data provider simulates API responses and is included in the Git repository or the resources of the “Assignment - Star Wars Planets Stats - Description and requirements” lecture.
The mock data ensures the application remains functional without relying on an external API. The source code for MockStarWarsApiDataReader is available in the src/ directory.
An optional feature of this project is a generic table printer that can display any collection of objects in a tabular format. This printer:
- Uses Generics to accept any object type.
- Renders properties dynamically in an ASCII table.
- Example output for planets:
+----------------+------------+------------+ | Name | Diameter | Population | +----------------+------------+------------+ | Tatooine | 10465 | 200000 | | Alderaan | 12500 | 2000000000 | +----------------+------------+------------+
Check the src/TablePrinter.cs file for the implementation details.
We welcome contributions to make this project out-of-this-galaxy! 🌠 To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature). - Make your changes and commit (
git commit -m "Add your feature"). - Push to your branch (
git push origin feature/your-feature). - Open a pull request.
Please read our Contributing Guide for more details.
Have questions or suggestions? Open an issue
This project is licensed under the MIT License. See the LICENSE file for details.