Station Machination Problem Description
You have been given the task to create a program that will find the next earliest train departure after your arrival at the station. This program will notify the user of the next train departure they should board using information from a timetable containing multiple entries of the starting station, destination station and the time the train is departing the starting station. The timetable will be in the form of a text file which will contain the source, destination and departure times of all trains on the rail network. The timetable information will be read by your program from standard input. The user will provide command line arguments, providing the source, destination and time of arrival at the source station.
Program Structure Timetable Data
The train network timetable will be presented in a double colon separated format. The format will specify the source, destination and leaving time from the source station.
Copyright By PowCoder代写 加微信 powcoder
The source and destination component may contain spaces and will be sub-strings of the line entry. Each entry in the timetable is separated by a new line. Following the
Your submission must be able to handle erroneous data that is contained within the schedule. This may include entries that contain an inappropriate number of colons or breaks, missing source, destination and time information as well as invalid time formats.
To clarify, You do not need to handle intermediate stations
Standard Input
Your program will need to accept the train network schedule via standard input. The data will be pushed into standard input via redirection and you will be able to use any allowed function that can operate directly on standard input such as fgets , fscanf , fread .
./timetable < timetable.csv
Do note, your program cannot hold all the data from the file in main memory as per the restrictions of this assignment, you will need to process it, line by line. If no data is supplied, your program should output to standard error No timetable to process .
You should only read through the file once, your program should not attempt to re-read the data after it has been read. Please do not attempt to use rewind or fseek on standard input.
Command Line Arguments
The search criteria is passed to the program via command line arguments, your program will need to accept all three command line arguments or it should otherwise quickly exit and output how to use the program. Refer to to the Not Enough Arguments section.
The command line arguments are given in the format and order:
./timetable
./timetable Wirragulla Cardiff “10:20:05” < timetable.csv The next train to Cardiff from Wirragulla departs at 10:30:23 Single Station 2 timetable.list ::Morisset::19:09:14 ::Morisset::19:54:14 ::Morisset::20:01:14 ::Morisset::20:46:14 ::Koolewong::19:43:40 ::Koolewong::20:01:40 ./timetable " " Koolewong "19:45:15" < timetable.list The next train to Koolewong from departs at 20:01:40 Multiple Stations timetable.list Sydney::Melbourne::08:05:00 Sydney::Melbourne::09:32:45 Sydney::Melbourne::11:45:32 Sydney::Melbourne::13:12:19 Sydney::Melbourne::19:59:15 Sydney::Melbourne::22:32:21 Melbourne::Sydney::14:13:12 Melbourne::Sydney::16:55:12 Melbourne::Sydney::18:33:12 Melbourne::Sydney::20:25:12 Melbourne::Sydney::22:22:12 ./timetable "19:40:59" < timetable.list The next train to Melbourne from Sydney departs at 19:59:15 Missing Station timetable.list Sydney::Melbourne::08:05:00 Sydney::Melbourne::09:32:45 Sydney::Melbourne::11:45:32 Sydney::Melbourne::13:12:19 Sydney::Melbourne::19:59:15 Sydney::Melbourne::22:32:21 Melbourne::Sydney::14:13:12 Melbourne::Sydney::16:55:12 Melbourne::Sydney::18:33:12 Melbourne::Sydney::20:25:12 Melbourne::Sydney::22:22:12 ./timetable "19:40:59" < timetable.list No suitable trains can be found Not enough arguments ./timetable < timetable.list Please provide
Code Submission
Your code submission must be made via git. You are able to retrieve the git repository link from the code submission section. The following rules apply to your code submission:
Only the last submission will be graded.
Submission after the due date will incur a late penalty as described in the unit of study outline.
Your submission must be able to compile with the given compilation command (using libasan is used in the compilation of your submission. This will check your program for memory related errors that occur at runtime.
Marking Criteria
The following is the marking breakdown, each point contributes a portion to the total 10% of the assignment. You will receive a result of zero if your program fails to compile.
3% Test Cases – Your program must pass public, private and hidden test cases to achieve the
maximum number of points awarded for this section.
6% Solution Discussion – You will need to answer questions regarding your implementation. You will be required to send answer after the code submission deadline. A reasonable attempt will need to be made, otherwise you will receive zero for the assessment.
you will need to explain:
How your code identifies invalid entries of timetable.list input.
How your code determines the answer to a query for multiple stations and why it is optimal and correct.
Answer further questions.
Your code will also be assessed on C coding style conventions (see Ed resources). Clean code will attract the best grade.
1% Your test cases – Your solution must include a suite of test cases that should be automated and executable with the given make script. Please make sure your test suite outputs the result of each test case in a human readable format.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com