-
Car Entry
- Users input car names (comma-separated).
- Each name must be non-empty and 5 characters max.
- Example:
pobi,woni,jun
-
Rounds
- Users enter the number of race rounds.
- Each round, every car either moves forward or stays still.
-
Movement Mechanics
- Each car has a 60% chance to move forward per round.
- Random number [0-9] is generated → moves if number ≥ 4.
-
Visual Progress
- After each round, each car’s position is printed with hyphens:
pobi : -- woni : ---- jun : ---
- After each round, each car’s position is printed with hyphens:
-
Winning Criteria
- After the final round, the car(s) with the maximum distance win.
- Ties are allowed — multiple winners are displayed comma-separated.
-
Input Validation
- Invalid inputs (e.g. empty names, too long, negative rounds) will result in an
IllegalArgumentExceptionand program termination.
- Invalid inputs (e.g. empty names, too long, negative rounds) will result in an
Enter the names of the cars (comma-separated):
pobi,woni,jun
How many rounds will be played?
5
Race Results
pobi : -
woni :
jun : -
pobi : --
woni : -
jun : --
pobi : ---
woni : --
jun : ---
pobi : ----
woni : ---
jun : ----
pobi : -----
woni : ----
jun : -----
Winners : pobi, jun
- Car names and number of rounds inputs
- Movement logic with random number generation
- Round-by-round progress display
- Multiple winner support
- Exception handling for invalid input