Reference no: EM13865385
Overview
A holiday resort provides cabins for travellers to stay in overnight.
A ‘cabin' is a small wooden hut, containing bunk beds, table and chairs, a heater, and a small cooking area. Often the traveller will use the general campsite facilities for washing and showering. Some cabins are more expensive, and may have separate bedrooms and their own ensuite bathroom.
Each cabin has a fixed price, regardless of whether all the beds are used or not. Small cabins are usually hired by individuals or couples, larger ones by families. Travellers hire the whole cabin, not a bed in a cabin.
Each cabin has a named owner. For this course, you can assume that owner names are unique.
In this assignment you will develop an application to hold details of all the cabins on the site, including their cost per night, and produce a report which includes a list of cabins and some summary statistics.
You should be able to make a start on your Cabin class after the first few lectures, and you will be able do most of the assignment after ArrayLists have been covered. You can finish it after the lecture on file i/o and exceptions.
In other accommodation types e.g. Hotel-room you should focus on using fields, which refer to a realistic booking option, e.g. Double room or single room.
Stage One - development your cabin class
The application is all about cabins, so there should be a cabin class. Develop your cabin class, and, using a main method, create several cabins and test the methods.
Don't use input or output files or any sort of graphical user interface in this stage. Just develop your cabin class, without the list of costs. Using a main method, create several objects of the class, and test all your methods, which you will use in the next stage.
Details for each cabin should be held in a class named either NameCabin (where Name is your initials) or some more specific name e.g. ArgyllHolidayVillage. Develop this class, according to the requirements that are listed below. Some of these requirements are described fully, and in other cases you have to make some of your own decisions.
When you have to make your own decisions, don't make the same decisions as your friends. You will lose marks if you hand in work in which all design decisions and code structures are identical to those of other students.
Your cabin class - Instance variables
For each cabin, you should hold the following essential information in instance variables:
• Cabin number e.g. 8
• Number of beds, from 2 to 8.
• Facilities - decide on two or three categories of cabin which will affect the price. For example, whether ensuite or not.
• Owner - just store the name, and assume this will be unique. Use the Name class.
You should also include some extra information (choose this to make your coursework a little different from that of your friends). Students working alone should include 2 extra items, and students working in pairs should include 4 extra items. Suitable extra information might be related to appearance, age or size. But you can choose anything sensible. There are classes in java to store dates, but they are a little complicated, so for this assignment you could either: investigate how to do this; restrict date information to the year; not store date information.
Your cabin class - Methods
The cabin class should have (use exact method names please):
• A Constructor, and get and set methods.
• A getCost() method which returns the cost of the cabin for one night. The cost should be the same all the year round. Invent your own pricing algorithm, which should be different to that of other students. You should take the type of facilities and number of beds into account, and maybe one or two of the extra details. Use class constants rather than literals in your calculation.
• AgetFullDetails() method which returns a String containing all the details of the cabin (including your extra attribute) as text. It should be clear what all the values are.
• AgetShortDetails() method which returns a String containing ONLY the cabin number; the cost; the owner initialsrather than full name; the number of beds in the cabin; the cost for one night.
Stage Two -alter your cabin class
In this version, all the cabins need to be hard-coded in a populatemethod, and output printed to System.out. In the final version, you will use text files.
Add and test the following features:
1. In the Cabin class, replace the simple ‘number of beds' by showing the number of beds in each room in the cabin, using an array of integers. E.g. :
• one room, 2 beds {2}
• three rooms, two with 2 beds and one with 3 {2,2,3}
There should be a method to return the total number of beds in the cabin.
2. Introduce a Managerclass and a CabinList class to contain an ArrayList of cabins, containing between 10 and 20 cabins, with features carefully chosen to test all your methods. All costs should be displayed showing 2 decimal places, e.g. 12.50. This class should include methods to:
• Return text consisting of details of all the cabins. These details should be formatted into a table, and should include the cabin number; the cost; the owner initials; the number of beds in the cabin rather than the beds per room; the cost for one night; anything else that you think should be included.
• Return a cabin object corresponding to a cabin number which is provided as a parameter.
• Return text giving full details of a single cabin, corresponding to the cabin number provided as a parameter. Use the previous search method then produce text containing all details, including the full name of the owner and full details of beds and rooms.
• Return the maximum income that the site could get per night - the sum of the cost of each cabin
• Return the cost of the cheapest cabin
• Return the cost of the most expensive cabin
• Return the number of cabins on the site
• Return a frequency report of your choice. Decide whether using a frequency array is useful for your choice. Examples:
a. The number of cabins with particular facilities
b. The number of cabins sleeping 1,2, 3, ..., 8 people
Using a main method, create several objects of the class, and test all your methods.
Stage Three
Replace your populate method with a method to read in the cabin data from a text file. Include a few errors in the text file and improve your program to cater for these errors, outputting a useful message and ignoring the line with the error.
Alter your program so that the frequency reports and other statistics obtained in (2) above are written to a text file.
You should provide a report on your program, consisting of the following information (nothing else):
1) Your decisions
a. Which extra accommodation attributes you chose
b. How the overall cost is calculated. Include an activity diagram.
2) Status report. Does your program meets the specification fully, or is it incomplete? This can be very brief (don't provide a list of everything that you were asked to do - the marker knows this). E.g.
• "This application meets the specification fully"
• "The application does everything except allowing the user to enter a accommodation number"
• "This application meets the specification almost completely but I know the cost calculation isn't always correct "
For the following lists and tables, there are examples in the Testing lecture.
• If necessary, a list of known bugs and a list of requirements that you have not implemented.
• Include a table of limitations - these are things that you decided not to handle, either through lack of time or because you think that they are unlikely to occur.
• Include a table of tests done.
3) Diagrams
• Class diagram showing all classes with instance variables, methods and associations
• A sequence diagram showing a task of your choice, but using at least 2 classes. E.g. reading the input file or creating a report.
4) Write javadoc style comments for the CabinList class, and generate the html. Hand in a printed copy of the html generated for the CabinList class.