Assignment 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

CSSE2002 / CSSE7023

Semester 1, 2012

Assignment 1
Goal: The goal of this assignment is to gain practical experience with data abstraction, unit testing and using the Java class libraries. Due date: The assignment is due at 5pm on Monday 16 April. Late assignments will lose 20% of the total mark immediately, and a further 20% of the total mark for each day late. Problem: In this assignment, and the following two assignments in this course, you will develop the component classes of a program to simulate the control tower of an airport by assigning flights in a schedule to runways. In this assignment, you will be writing data types for describing flights, flight schedules and runways, by completing the Flight, Schedule, and Runway classes. All of these classes are included in the Zip file. In brief: A Flight is an immutable description of a flight, in terms of its flight number, the time it is ready to use a runway, the amount of time it requires on a runway, in addition to whether it is either arriving or departing. A Schedule is a mutable collection of flights that does not contain duplicates. The constructor creates an empty Schedule to which individual flights may be subsequently added, one at a time. The addition of a flight is only possible if an equivalent flight has not already been added. A Schedule has methods to retrieve the flights for a given arrival/departure time, and the arrival/departure time of the last arriving/departing flight in the schedule. When retrieving flights for a given time, the flights should be returned in the order in which they were added to the Schedule. A Runway represents a single, mutable runway in terms of the flight, if any, that is currently using it, the amount of time the current flight, if any, has been using the runway, and the queue of flights that are waiting to use it to either land or take off. The constructor creates a new Runway that has no flight using it or waiting to use it. Flights may be added, one at a time, to the waiting queue of the Runway, and the state of the runway may be updated, to mark the passing of a unit of time. A Runway has methods to check if there are already other flights waiting to use or currently using the runway, and to retrieve the amount of time a given flight would have to wait to use the runway in its current state. Practical considerations: Skeletons for the classes you must implement are provided in the Zip file. These skeletons include Javadoc specifications of the constructors and methods that you need to complete. You will need also to declare variables, add import clauses, and add comments and javadocs as required. Copy or rename the skeleton files before you start. (Dont forget that the package and class names inside the files must correspond to the file and the directory names otherwise youll have difficulty compiling and running it.)

You must implement these classes as if other programmers were, at the same time, implementing the code that instantiate them and call their methods. Hence: The class names must be as above, and they must be in the package simulator Dont change the specifications provided, or alter the method names, parameter types or return types. You are encouraged to use Java 7 SE classes, but no third party libraries should be used. (It is not necessary, and makes marking hard.)

Implement the Flight, Schedule and Runway 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, and use embedded whitespace consistently. Your code should use private methods and private instance variables and other means to hide implementation details and protect invariants. Your methods, fields and local variables (except for-loop variables) should have appropriate Javadoc comments or normal comments. Comments should be used to document your codes invariants, and to describe any particularly tricky sections. (You must provide an implementation invariant for each of the Flight, Schedule and Runway classes). 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 straight-forward way. The checkInv() method of each class should check that the implementation invariant you have specified in your comments is satisfied.

The Zip file for the assignment also includes an InvalidTimeException, DuplicateFlightException and an InvalidDurationException for exceptional circumstances and some sample junit test classes. The exceptions are necessary to compile your classes, and the junit test classes are provided to help you get started with testing your code. The junit test classes as provided in the Zip file 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. However, you should not submit your test code. You should only submit your implementations of the classes you have implemented. (We will test them using a more 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 newsgroup, ask a tutor, or email the course coordinator to clarify the requirements. Real software projects have requirements that arent entirely clear, too!

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 the course web site, and during the lectures. Hints: 1. It will be easier to implement both Schedule and Runway after you have implemented the Flight class. 2. Read the specification comments carefully. They have details that affect how you need to implement and test your solution. Submission: Submit your files Flight.java, Schedule.java and Runway.java electronically using Blackboard: http://blackboard.elearning.uq.edu.au You can submit your assignment multiple times before the assignment deadline but only the last submission will be saved by the system and marked. Only submit the source (i.e. .java) files for the Flight, Schedule, and Runway classes. Any further instructions about the submission will be posted on the newsgroup. Evaluation: Your assignment will be given a mark out of 10 according to the following marking criteria. Testing (5 marks) All of our tests pass At least 3/4 of our tests pass At least 1/2 of our tests pass At least 1/4 of our tests pass Work with little or no academic merit 5 marks 4 marks 2 marks 1 mark 0 marks

Note: code submitted with compilation errors will result in zero marks in this section. Code quality (5 marks) Code that is clearly written and commented, and satisfies all specifications, style rules and rules of data abstraction Minor problems, e.g., lack of commenting or private methods Major problems, e.g., code that does not satisfy the specification or rules of data abstraction, or is too complex, or is too difficult to read or understand Work with little or no academic merit 5 marks 3-4 marks

1-2 marks 0 marks

Note: you will lose marks for code quality a) for breaking java naming conventions, b) failing to comment tricky sections of code,

c) inconsistent indentation and / or embedded white-space, and d) lines which are excessively long (lines over 80 characters long are not supported by some printers, and are problematic on small screens). School Policy on Student Misconduct: You are required to read and understand the School Statement on Misconduct, available on the Schools website at: http://ppl.app.uq.edu.au/content/3.60.04-student-integrity-and-misconduct This is an individual assignment. If you are found guilty of misconduct (plagiarism or collusion) then penalties will be applied. If you are under pressure to meet the assignment deadline, contact the course coordinator as soon as possible.

You might also like