Nowadays, road safety research provides an important support for the transport policy. This type of research is concerned with meeting road casualty reduction targets in a country. In order to meet this primary objective, research is commissioned to analyze and understand various vehicle accident types and the factors influencing it. The most common types of accidents are single vehicle collisions, rear-end collisions, head-on collisions, and side impact accidents. Therefore, there has been an increasing demand for more up to date information on reported traffic accidents to be made available to researchers. As a result, in many countries, a department for transport (DfT) is responsible for collecting and publishing traffic accidents data.
In this TMA you’re required to help researchers and implement a Vehicle Accident Application to keep track of accidents data. The requirements for this application are in the following phases:
Phase 1:
Create a separate class each in a .java file to represent vehicle accidents data occurred in a country, an accident, a vehicle and a driver.
The vehicle accidents class has attributes to store a country name and a list of published accidents data by the DfT in that country. The accident class keeps the details about collision road location (within urban area, highway), date/time, the vehicles associated and the number of casualties.
Note: Use the Date class available in java.util package to represent the accident data/time.
Each vehicle has a number and a driver. The driver class records the driver’s name, age, gender and his/her license issue date. The reported vehicle accidents are of the following types:
1. Single vehicle accident: This is a type of road traffic accident in which only one vehicle is involved. A majority of these types of crashes are collisions with fallen debris, a pole, a tree, a wall, and collisions with animals.
2. Rear-end accident: A traffic accident where a vehicle crashes into the vehicle in front of it. Sudden deceleration (slowing down or braking) is a common cause of such accidents.
3. Side-impact accident: These accidents, also known as broadside or T-bone collisions, are where the side of one or more vehicles is impacted. These crashes commonly occur at intersections and parking lots. The results from a side-impact collision can be severe but can vary depending on where the vehicle is struck.
4. Head-on accident: This type of accident is when the front ends of two vehicles hit each other in opposite directions. Being aware of traffic signs, street conditions, and staying in your lane play a critical role in avoiding these types of accidents.
Create a class for each vehicle accident type and define necessary attributes and methods.
Each class must store its state in private variables. It should use a static variable to maintain a count of all instances of the class. For All required access is done through public methods. The public methods which you must implement allow the user to do the following:
- Initiate, get and set the state of any created object.
- Create a new vehicle accidents data object for a given country.
- Add a reported accident type to the list of accidents if is not already in the accidents list.
- Find and display the most frequent accident type from the collected data.
- Display percentage of causalities in accidents involving drivers over age 65.
- Compare the number of accidents that occur within build-up areas to those accidents that occur on highways.
- Display the country name and accidents list which shows the accident details for the drivers involved in accidents having driver's license issued after 2015.
- Dump the vehicle accidents data structure into text.
- Save the information of the vehicle accidents data structure into a file.
If the user attempts do an operation that will violate the state of objects, you must check for it. In that case, the operation should be ignored and the application should give back an error message.
Phase 2:
The application should use a text file to capture the whole vehicle accidents data structure. To do this, add two methods to your center class:
1. A method to save the content of the created Java structure into a text file.
2. A method to restore the saved content back into an appropriate Java data structure for next run time.
Java provides a facility to create your own Exceptions which are basically derived classes of Exception. Write a class that defines a duplicate exception. The duplicate exception will be thrown if accidents are duplicated in the accidents list.
Design and implement a separate testing class to test the designed classes and check if classes meet the requirements.
Phase 3:
The application has to be a GUI (Graphical User Interface) application. Create a window that includes a window title: Title of your project. Design your window by using minimum four different user interface controls like labels, text field, buttons, text area, etc.
Question:
What is the best choice to reuse your written code, if the researchers want to study not only the impact of road location but also other road characteristics such as its surface (dry, wet, slippery…), sign posting, paving, …etc on the accident types? Justify your answer.