Skip to content

The program simulates a console-based car racing game using async/await to assign each car its own thread for simultaneous racing.

Notifications You must be signed in to change notification settings

cecilia-coutinho/car-racing-console-csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚗🚧 Car Racing Console Simulator 🚩

by Cecilia Coutinho

🌍 Overview

The Car Racing Console Simulator is designed to run a car racing game where multiple cars compete against each other in a console-based environment, with no graphics. The system includes random events that may occur during the race to add excitement and unpredictability. The program utilizes asynchronous programming using the async/await keywords and each car is assigned its own thread, allowing multiple cars to race simultaneously without interfering with each other. The use of async/await ensures that the program does not block the main thread while waiting for tasks to complete.

📋 MVP

The Minimum Viable Product(MVP) of the Car Racing Console Simulator includes the following features:

🎯 Simulation of a race with multiple cars.

🎯 Simulation of random events that may occur during the race.

🎯 Implementation of logic for each car to run on its own thread.

🎯 Tracking of the time spent by each car and identification of the winner.

🎯 Printing of status updates in console when a car experiences a problem or reaches the finish line.

💻 Technology Stack

📌 C#: primary language.

📌 .NET6: software framework.

📌 Git: version control.

📌 Visual Studio: IDE.

📏 Project Methodology

📝 Kanban

💭Reflections or Aditional Info

The code simulates a simple race between multiple cars and demonstrates the use of asynchronous programming, as well as using C# interfaces to produce events' behaviour. It's a functional console-based car racing simulation system with no graphics.

The program uses asynchronous programming concepts to start the races concurrently and simulate different events that can happen during the race. The simulation of each event is defined in classes that implement the IEvent interface. The race simulation is performed in the StartRace() method, which calculates the time it takes to finish the race based on the distance and speed of the car and simulates different events by calling the Apply() method of a random event from the RandEvents list.

The winner of the race is determined by comparing the Elapsed Time property of the Race object of each car. The DefineWinner() method is called after all races are completed, and it determines which car finished first and prints the result.

About

The program simulates a console-based car racing game using async/await to assign each car its own thread for simultaneous racing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages