Project

Traffic Light Simulator with Java

Hard
231 completions
~ 24 hours
3.9

By the end of this project, in addition to creating your own "traffic light", you will learn how to work with multi-threading, handle exceptions, inherit classes, and implement and apply the circular queue data structure

Provided by

JetBrains Academy JetBrains Academy

About

Do you know how traffic lights were invented? Some time ago, it was decided to replace the traffic police officers with a looped automated system that gives information to drivers about whether they can continue driving or not. In this project, we will implement a simplified version of such a system for a road junction in which many roads converge to one. You will practice concepts frequently tested in technical interviews at top tech companies.

Training project icon

Training project

This project allows you to practice and strengthen your coding skills, helping you get ready for more advanced tasks ahead.

What you'll learn

Once you choose a project, we'll provide you with a study plan that includes all the necessary topics from your course to get it built. Here’s what awaits you:
Output the simple list of options as a control panel for a future traffic light.
Good traffic light knows how many roads it controls and the interval between the opening and closing of the road. Input these two values to a program and implement the looped menu's option selection with simple stubs.
What if the user inputs "Hello" as the number of roads? The program will terminate with an exception, but the good traffic light should not stop working because of the user's mistake. Handle it and print the appropriate feedback.
Let's continue working with our menu. When the initial settings are provided, create a new thread that will start counting the seconds.
Let's give users the option to add and delete new roads. Roads open in a cyclical order, so don't forget to implement the circular queue as a buffer to store elements.
Our traffic light doesn't work as expected; it only shows the information about roads that were added to a road junction. Each time the system updates the output, calculate the exact time to close/open for each road.

Reviews

Pavel švarc avatar
Pavel švarc
2 weeks ago
This was quite step up in difficulty of content. I agree that sometimes description what is expected is not fully clear and require quite some guessing. But at the end of the day this project teach you a lot of things. So I am ok with it :)
Alimdar avatar
Alimdar
3 weeks ago
That was great project, but the last stage was very hard to pass.
Suryakumar Selvakumar avatar
Suryakumar Selvakumar
3 months ago
I learned to work with circular queues, threads, and multi-threading

3.9

Learners who completed this project within the Java Desktop Application Developer course rated it as follows:
Usefulness
4.4
Fun
3.8
Clarity
3.5