Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program Description: Horserace!!! The idea is to create a graphical program using JavaFX that will race horses across a window in Java. The program will

Program Description: Horserace!!! The idea is to create a graphical program using JavaFX that will race horses across a window in Java. The program will be an application that will instantiate multiple instances of RaceHorse threads. The application will run in a window that will contain three buttons: [run race] [reset race] [quit program] A total of 5 horses will run the race. When the application starts, the horses will be lined up at the starting line. When the user clicks the [run race] button, the horses run. Your program will animate their running across the window, ultimately declaring a winner. Notice there is literally a race condition in this program: You must ensure that the horse that crosses the finish line first detects that it has won, declares itself the winner, and ensures that the other horses do not declare themselves winners, all as an atomic operation. Your program will need a lock for the critical section of code. It might have a shared memory condition variable (keepRunning or some such) that tells the other horses when to stop running. You might use the interrupted exception to stop the horses from running if you wish. You may use whichever method seems the most direct to you. Certainly, you will not use the thread.stop() method in the Java program to stop the other horses from running (for reasons to be described in class). When a horse crosses the finish line, you will declare a winner via a dialog box. The dialog box will also report the winning time. You will use a timer as was demonstrated in the selection and merge sort programs. The timer returns milliseconds which you will convert into seconds and report in the dialog box. The user will click the dialog to close it. If the user then presses the [reset race] button the horses should be redrawn back at the starting line. If the user clicks the [quit] button, the program should terminate. All the buttons should work properly. Some interface design in alerting the user how to use the interface will be needed. Be sure your program does not generate runtime errors if the buttons are clicked in an incorrect pattern. Testing your Program 1. I will test your program on Windows from a batch file you will create. I will not go through determining if it needs to go into Eclipse, Netbeans or Linux (which, or course, requires the additional steps of running Filezilla, getting end of line handling fixed, and making any scripts executable, which they are NOT when first copied to Linux). 2. If you have developed in Eclipse Intellij, or Netbeans, comment out any package statements these environments automatically included before submitting. Be sure any files that must be read are either in the directory where your .class files will be created or in a directory beneath, with a suitable relative path to the directory in your source code. 3. NEVER hardcode an absolute path to ANYTHING in any program in this or any other course. If you code something like: d:\somebodysname\myfiles\hereitis in your program, I GUARANTEE your program will not work when I try to run it in my environment. 4. I will expect my utility to unzip your project automatically into a folder that has your name on it and to run your batch file to exceute your program.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions