Java代写:CSSE7023-Train-Management-System

Requirement

In this request, you will continue to implement the component classes of a program for simulating the behaviour of a train management system.

Task Overview

In brief, you will write a method for reading in the sections of a track from a file, and you will write a method for allocating routes to trains (so that they don’t collide). If you are a CSSE7023 student you will also be required to write a JUnit4 test suite for testing the track-reading method.

More specifically, you must code method read from the TrackReader class and method allocate from the Allocator class that are available in the zip file that accompanies this handout, according to their specifications in those files.

If you are a CSSE7023 student, you will also need to complete a systematic and understandable JUnit4 test suite for the read method in the skeleton of the TrackReaderTest class from the railway.test package. You may write your unit tests assuming that the classes that TrackReader depends on (e.g. the Junction, Section, Track classes and any of the Java 8 SE API classes) are implemented and functioning correctly. That is, you don’t need to create test stubs for these classes.

As in request 1, you must complete these methods and classes as if other programmers were, at the same time, implementing classes that use it. Hence:

  • Don’t change the class names, specifications, or alter the method names, parameter types, return types, exceptions thrown or the packages to which the files belong.
  • You are encouraged to use Java 8 SE API classes, but no third party libraries should be used. (It is not necessary, and makes marking hard.)
  • Don’t write any code that is operating-system specific (e.g. by hard-coding in newline characters etc.), since we will batch test your code on a Unix machine.
  • Any new methods or fields that you add to TrackReader or Allocator must be private (i.e. don’t change the specification of these classes.)
  • Your source file should be written using ASCII characters only.

Implement the classes as if other programmers are going to be using and maintaining them. Hence:

  • Your code should follow accepted Java naming conventions, be consistently indented, readable, and use embedded whitespace consistently. Line length should not be over 80 characters. (Hint: if you are using Eclipse you might want to consider getting it to automatically format your code.)
  • Any additional methods that you write, and fields that you introduce should be private to hide implementation details and protect invariants.
  • Private methods that you write must be commented using preconditions and postconditions (require and ensures clauses). Informal description is OK.
  • Fields and local variables (except for-loop variables) should have appropriate comments. Comments should also be used to describe any particularly tricky sections of code. However, you should also strive to make your code understandable without reference to comments; e.g. by choosing sensible method and variable names, and by coding in a straightforward way.
  • Any exceptions that are created and thrown should have appropriate messages to help the user understand why the exception was thrown. This is particularly important for the read method in TrackReader, since if there is an error with the file format, then the user will want to know what is wrong with it when a FormatException is thrown. Each FormatException thrown should have a meaningful message that accurately describes the problem with the input file format, including the line of the file where the problem was detected. (You can create a new FormatException with a message using the constructor that takes a string parameter.)
  • The methods that you have to write must be decomposed into a clear and not overly complicated solution, using private methods to prevent any individual method from doing too much.

I recommend that you attempt to write loop invariants for all non-trivial while-loops in your code, but this is not compulsory.

The Zip file for the request also includes some other code that you will need to compile your classes as well as some junit4 test classes to help you get started with testing your code.

Do not modify any of the files in package railway other than TrackReader and Allocator, since we will test your code using our original versions of these other files. Do not add any new files that your code for these classes depends upon, since you won’t submit them and we won’t be testing your code using them.

The JUnit4 test classes as provided in the package railway.test are not intended to be an exhaustive test for your code. Part of your task will be to expand on these tests to ensure that your code behaves as required by the javadoc comments. (Only if you are a CSSE7023 student will you be required to submit your test file TrackReaderTest.java.) We will test your code using our own extensive suite of JUnit test cases. (Once again, this is intended to mirror what happens in real life. You write your code according to the “spec”, and test it, and then hand it over to other people … who test and / or use it in ways that you may not have thought of.)
If you think there are things that are unclear about the problem, ask on the piazza forum, ask a tutor, or email the course coordinator to clarify the requirements. Real software projects have requirements that aren’t entirely clear!

If necessary, there may be some small changes to the files that are provided, up to 1 week before the deadline, in order to make the requirements clearer, or to tweak test cases. These updates will be clearly announced on the Announcements page of Blackboard, and during the lectures.

More about the allocate method from the Allocator class

In this section we explain some of the terminology used in the specification of the allocate method.

Submission

Submit your files TrackReader.java, Allocator.java (and TrackReaderTest.java and any of your track files that are used for testing in TrackReaderTest.java if you are a CSSE7023 student)
You can submit your request multiple times before the request deadline but only the last submission will be saved by the system and marked. Only submit the files listed above.
You are responsible for ensuring that you have submitted the files that you intended to submit in the way that we have requested them. You will be marked on the files that you submitted and not on those that you intended to submit. Only files that are submitted according to the instructions on Blackboard will be marked.

Evaluation

If you are a CSSE2002 student, your request will be given a mark out of 15, and if you are a CSSE7023 student, your request will be given a mark out of 17, according to the following marking criteria. (Overall the request is worth 15% for students from both courses.)

Code quality

Note: you will lose marks for code quality for:

  • breaking java naming conventions or not choosing sensible names for variables;
  • inconsistent indentation and / or embedded white-space or laying your code out in a way that makes it hard to read;
    having lines which are excessively long (lines over 80 characters long are not supported by some printers, and are problematic on small screens);
  • exposing implementation details by introducing methods or fields that are not private
    not commenting any private methods that you introduce using contracts (pre and postconditions specified using @require and @ensure clauses).
  • not having appropriate comments for fields and local variables (except for-loop variables), or tricky sections of code;
  • not setting an appropriate message for exceptions that are created and thrown
    monolithic methods: if methods get long, you must find a way to break them into smaller, more understandable methods using procedural abstraction. (HINT: very important!)
  • incomplete, incorrect or overly complex code, or code that is hard to understand.
  • To make sure that your lines are not over 80 characters, you should indent using spaces and not tabs, since tabs may be interpreted as different numbers of characters depending on your code browser. You can set the Eclipse formatter to do this for you.
    #Fundamentals