UNF
University of North Florida
School of Computing
Project 2 - Road Section Data
Objective:
•
Show an understanding of how to
Use an input stream to read in data from a delimited text file
○ Create object class files based on input files and output requirements
○
Use existing methods to convert dates into different formats
○
Use an output stream to create a delimited text file
Catch and recover from exceptions that can occur
COP3503
Submission:
Project 2 requires that you submit 1 zip file to Canvas as specified below.
• Submit your project via the Canvas course
о Upload a zip file containing the 6 files required for the project. Follow the naming
convention below.
○
○
○
Flowchart.jpg/png
Project2.java
FileHandler.java
RoadVolume.java
RoadSpeed.java
RoadSection.java
The zip file should be named Project2_N#.zip
For example: Project2_n00123456.zip
The zip file should not contain any additional files
This includes input and output files
The files should be named as shown above
Only the zip file name should contain your N#
After submitting to Canvas download and double check submission
No late files will be taken after the submission date
Description:
The Road Section Data program combines volume and speed data for a given section of roadway. The
program will read in data from two files one containing speed data and the other volume data. The data
sets must be linked together based on their date and time attributes. This will allow for a new data set to
be created that stores the related volume and speed data along with the total volume and average
volume/speed for a given date and time. UNF
University of North Florida
School of Computing
COP3503
Requirements:
Documentation Requirements: 10 points
• 10 points: Create a flowchart that outlines the logic implemented in the create RoadSections
method
○ You must use a flowcharting program to create this diagram – NO Hand drawn diagrams
○
○
Free Recommended option draw.io
Make sure to export the flowchart from the flowcharting program.
DO NOT take a screenshot
Create the flowchart after completing the code for Project 2. The diagram must
accurately reflect your implementation of project 2
Minimum Implementation Requirements:-100 points
The requirements listed below must be implemented correctly or no points will be given for the project.
•
•
•
Must use at least 1 try-catch in your project
о Your try-catch/s should catch, handle, and recover from FileNotFoundExceptions, and
ParseExceptions
All 5 class files must be present in the submission
Poject2.java, FileHandler.java, RoadSpeed.java, RoadVolume.java, & RoadSection.java
All methods and variables shown in the UML class diagrams must be present in each class file
See below for UML class diagram
○
Failure to meet the requirements listed above will result in a zero for the project.
Style Requirements: Required
Javadoc's: -10 points
•
Each class and method declaration must have a correct Javadoc comment placed above it
Add your Javadoc comments last
Generate the Javadoc's using an IDE and verify no errors or warning are produced
Naming Conventions: -10 points
• Each class, variable and method must be named appropriately
○
Variables and methods always start with a lowercase letter
○ Classes always start with an uppercase letter
Implementation Requirements: 90 points
Load Volume Data:
Use the method in FileHandler called loadVolume Data to handle this task.
•
Prompt the user for the path/filename of the volume data file then pass the provided string to
the loadVolumeData method
○
If the input given by the user results in a FileNotFoundException alert the user to the
error and re-prompt them for good input
○
The user providing an invalid path should not cause the program to crash or stop
running UNF
University of North Florida
School of Computing
COP3503
Recommend setting the loadVolumeData method to throw the FileNotFoundException
Catch and recover from the exception in the calling method that takes in the
filename
Read in the data from the provided volume data file and store the data for each row in a
RoadVolume object. Store each object created in an ArrayList.
○
○
If the input file given by the user contains bad date data and results in a ParseException
alert the user to the error and re-prompt them for good input
The user providing a file with bad date data should not cause the program crash or stop
running
Recommend setting the loadVolumeData method to throw the ParseException
Catch and recover from the exception in the calling method that takes in the
filename
Load Speed Data:
Use the method in FileHandler called loadSpeed Data to handle this task.
•
Prompt the user for the path/filename of the speed data file then pass the provided string to the
loadSpeed Data method
○ If the input given by the user results in a FileNotFoundException alert the user to the
error and re-prompt them for good input
о
○
The user providing an invalid path should not cause the program to crash or stop
running
Recommend setting the loadSpeedData method to throw the FileNotFoundException
Catch and recover from the exception in the calling method that takes in the
filename
Read in the data from the provided volume data file and store the data for each row in a
RoadSpeed object. Store each object created in an ArrayList.
О If the input file given by the user contains bad date data and results in a ParseException
alert the user to the error and re-prompt them for good input
о
О
The user providing a file with bad date data should not cause the program crash or stop
running
Recommend setting the loadSpeed Data method to throw the ParseException
Catch and recover from the exception in the calling method that takes in the
filename
Create Road Section Objects:
Use the method in Project2 called create RoadSections to handle this task.
• For each volume object find the matching speed object based on the date and time attributes
○
This can be done in reverse as well
Each speed object has a single volume object that contains a matching
date/time University of North Florida
COP3503
UNF
School of Computing
Once a matching volume and speed object has been found create a RoadSection object that
stores references to the matching volume and speed objects
○ Each RoadSection object created needs to be stored in an ArrayList
When the RoadSection object is created calculate the volume total, volume average, and speed
average based on the data stored in the matching objects
О Use the private methods in the RoadSection to calculate the values mentioned above
Write Road Section Data:
Use the method in FileHandler called write RoadSection Data to handle this task. Along with the
getFileData methods of each object.
getFile Data Method:
• The getFileData for the volume and speed data objects need to return their respective sensor
data comma separated
The RoadSection getFileData method needs to leverage the getFileData methods of the volume
and speed objects while appending the additional data needed
The string returned by RoadSection getFile Data must be comma separated and contain the
values for the attributes listed below
○
Date, Time, Volume_Sensor_2003, Volume_Sensor_2004, Volume_Sensor_2005, Volume_
Sensor,Speed Sensor_2282,Speed_Sensor_2293, Volume_Total, Volume_Avg,Speed_Avg
writeRoadSection Data Method:
• Create a new csv file called "Road_Section_Data.csv"
• Write out the following header to the csv file
О Header:
Date, Time, Volume_Sensor_2003, Volume_Sensor_2004, Volume_Sensor_2005, V
olume_Sensor,Speed_Sensor_2282,Speed_Sensor_2293,Volume_Total,Volume_
Avg,Speed_Avg
Then for each RoadSection object created call getFileData and write the returned string to the
new csv file
Class Diagrams:
Project2:
+ main(args: String[]):void
Project2
+ createRoadSections (volumeList: ArrayList speedList: ArrayList): void
FileHandler:
FileHandler
+loadVolumeData(filename: String): ArrayList
+ loadSpeedData(filename: String): ArrayList
+writeRoadSectionData(section List: ArrayList): void UNF
RoadVolume:
date: Date
-time: String
- volumeSensor1 : int
- volumeSensor2 : int
- volumeSensor3: int
University of North Florida
School of Computing
RoadVolume
- volumeSensor4: int
+ RoadVolume(date: Date, time:String, volumeSensor1:int, volumeSensor2: int, volume Sensor3:int, volumeSensor4:int)
+ getFileData(): String
+ getDate(): Date
+ setDate(date: Date) : void
+ getTime(): String
+ setTime(time: String): void
+ getVolumeSensor1(): int
+ setVolumeSensor1 (volumeSensor1: int): void
+ getVolumeSensor2(): int
+ setVolumeSensor2(volume Sensor2: int) : void
+ getVolumeSensor3() : int
+ setVolumeSensor3(volume Sensor3: int): void
+ getVolumeSensor4(): int
+ setVolumeSensor4(volumeSensor4: int): void
RoadSpeed:
Road Speed
- date: Date
-time: String
- speedSensor1: double
-speedSensor2: double
+ RoadSpeed(date: Date, time:String, speedSensor1:double, speedSensor2:double)
+ getFileData(): String
+ getDate(): Date
+ setDate(date: Date): void
+ getTime(): String
+ setTime(time: String): void
+ getSpeedSensor1(): double
+ setSpeedSensor1 (speedSensor1: double): void
+ getSpeedSensor2(): double
+ setSpeedSensor2(speedSensor2: double): void
RoadSection:
Road Section
- roadVolume: RoadVolume
- roadSpeed: RoadSpeed
- volume Total: int
- volumeAvg: double
- speedAvg: double
+ RoadSection(roadVolume: RoadVolume, roadSpeed: Road
+ getFileData(): String
+ getRoadVolume(): RoadVolume
+ setRoadVolume (roadVolume: RoadVolume): void
+ getRoadSpeed(): RoadSpeed
+ setRoadSpeed(roadSpeed: RoadSpeed): void
+ getVolume Total() : int
+ setVolume Total(total int): void
+ getVolumeAvg(): double
+ setVolumeAvg(avg: double): void
+ getSpeedAvg(): double
+ setSpeedAvg(avg double): void
- calcVolume Total() : int
- calcVolumeAvg(): double
- calcSpeedAvg(): double
COP3503