This assignment builds on your application, produced in Assignment 1, which holds a list of cabins, which can be either read in from a text file or just hard coded in a ‘populate' method. The statistical reports in Assignment 1 are not needed in this assignment. Contact the lecturer if you do not have a suitable ‘list of cabins' program.
Unlike assignment one, you should work on this assignment yourself, but you are of course welcome to discuss it with other students.
You should develop your program using incremental development. Develop your program a little bit at a time and keep testing it. Save a working version before making the next set of alterations. Then, if you run out of time, you can submit a program which provides some of the functionality. You will get very few marks for handing in lots of code that does not run correctly.
All code should be well-designed, well-laid out and commented.
Conditions for this coursework
All students MUST complete coursework to a satisfactory standard, you are not allowed to pass the course just on the examination alone, even if you score 100% in the exam which will give you 60% for a course mark. If you don't do the coursework this semester, you will be asked to do it later, although it wouldn't then count towards your final mark.
If you hand in work late, without extenuating circumstances, 10% of the maximum available mark will be deducted from the mark awarded for each day late.
Part One - UML Use case Diagram, Text description and Activity Diagram
You can draw these diagrams using any tool that you like - a UML tool, a drawing package, or by hand.
The scenario below is JUST for the use case and activity diagrams - the application that you are asked to write is a little simpler.
Draw a Use Case Diagram for the following scenario, and write a detailed description of the ‘book-in' use case - this is the numbered ideal scenario with alternatives (see slide 10 of Use case lecture). There are probably several equally correct interpretations of this scenario, so don't worry if you don't all have identical diagrams.
A campsite has a number of cabins which can be hired on a daily basis, and a number of grass plots for tents, caravans or motor homes. Cabins and plots will be referred to as ‘locations'. Travellers aged under 18 are not allowed to stay on this campsite.
Travellers cannot book in advance at this campsite, they just turn up and, as long as there is a free location, they are allocated a cabin or plot. When they arrive, they fill in a ‘visitor form' giving their personal details, and show their passport (which includes their date of birth). While they are doing this, the campsite staff fill in another form on the computer just entering the location id and the form number, and how many nights they are staying for. The traveller must pay the cost of the location for one night when booking in. Then the traveller is shown where their location is.
If the traveller wishes to stay an extra night, he must pay for that in advance. This can be done either when booking in, or at a later stage.
The campsite has a manager and several assistants. All campsite staff can book in travellers, and handle payment. In addition, the manager can view various reports on occupancy and income.
Draw two activity diagrams: one for the book-in use case, and one for some coding involving decisions in your application, for example the getCost() method.
Part Two - using Inheritance
Write your initial Plot class anytime, continue after the 3 inheritance lectures.
Keep a copy of Assignment One before continuing!
You are NOT being asked to develop a complete booking system here. You are not expected to cope with payment at all, or restrict access according to the type of user.
First write a Plot class and test using a main method, not using inheritance at all:
Decide on a small amount of information to keep for each plot. E.g. plot number, whether it has electricity or not, something else. Decide on a very simple calculation to work out the cost of each plot depending upon its attributes. Write a getCost() method. As in assignment one, your decisions should be different to those of your friends.
This application will only record whether a location is booked for the current night or not, and keep a count of how many times each location has been used. Now create a Location superclass and adapt your Cabin and Plot classes to become subclasses of Location. Test using a main method:
Use a superclass Location with subclasses Cabin and Plot.
The Location class includes any common attributes or methods shared by Plot and Cabin. One of these methods must be an abstract getCost() method.
In the Location class, also add in a boolean instance variable to show whether the location is booked or not for this night, and a count of the number of bookings for this location. Imagine that each day the computer is switched on and this booking boolean starts at ‘false'. Then when the traveller arrives, the booking is entered into the computer - this simply sets the booking boolean to ‘true' and increases the count of bookings for this location.
You need to alter your Cabin and Plot class so that they extend Location, and move any common attributes or methods to the Location class. Here is one way in which you could handle the ID: refer to the cabins using the prefix ‘C', and plots with the prefix ‘P'. So that, whereas before, cabins were numbered 1,2,3 etc, now locations are numbered C1, C2, C3, ......P1, P2, P3.....etc.
The Location class should return a String consisting of the location information (id, booked or not, count of bookings).
The Cabin and Plot class should have methods which return full details of the cabin or plot, and including the location information.
Extend your ‘list of cabins' application to become a ‘list of locations'. Read in cabin and plot data from 2 separate text files. For this application, you can assume that your text files contain correct data - you don't need to do any checking. You don't need methods such as min/max/total. You will need methods to:
• Search for a location given the id. This returns a Location object that you can use in other methods
• Return a String containing summary information for each location