Program for hold details of all the cabins for travellers, Programming Languages


A campsite 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.



Develop an application to hold details of all the cabins on the site, including their cost per night. 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.

Development before arrays have been covered

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.

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.

getCost() method

The Cabin class should have 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 groups. 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.

Intermediate version, to be completed after arrays and ArrayLists  have been covered.

In this version, all the Cabins need to be hard-coded in a 'populate' method, 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 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 rather than full name; the number of beds in the cabin rather than the beds per room; 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
  • Each person in the group should write a method to return a frequency report of their 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

Final version after lecture on file i/o.

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. 

Extra documents

You will also be asked to hand in a report on your testing, a class diagram and a sequence diagram, and to generate the javadoc to document one class for external use.

1)      Introduction, containing:

a.       which extra cabin attributes you chose

b.      how the cost of a cabin is calculated

c.       what the frequency report(s) show and which person wrote it

d.      Status report. Tell us whether you think that your program meets the specification fully, or whether you haven't quite finished it or know that there are some bugs that you can't solve. This can be very brief.  E.g.

i. "This application meets the specification fully"

ii. "The application does everything except the frequency report"

iii. "Our application can print a list of the cabins but we haven't done any other reports"

iv. "We've done everything in the specification but we know the maximum cost isn't correct"

2) Class diagram showing instance variables, methods and associations

3) A sequence diagram showing a task of your choice, but using at least 2 classes. E.g. working out the frequency report.

4) Code. Just print each file, in a monospaced font such as Courier, from a text editor or eclipse, you don't need to embed the code into a report.

5) Comment one class to Javadoc standards and generate the html.

6) Application report output, ideally from text file. Show each feature - list of cabins, examples of single cabin details, max income, cost of cheapest and most expensive cabin, frequency reports.

7)      Testing report. This could include explanation of choice of suitable cabin attributes, details of error checks on file input, and a list of tests passed, especially for methods involving decisions.

Additionally, submit your application as a single file through the link in Vision. You could submit a zipped eclipse project or a zipped file containing your java files and input text files. It should be possible for the lecturer to run your application if they wish to do so.


You have to write comment before each step using  //

Posted Date: 2/22/2013 8:21:43 AM | Location : United States

Related Discussions:- Program for hold details of all the cabins for travellers, Assignment Help, Ask Question on Program for hold details of all the cabins for travellers, Get Answer, Expert's Help, Program for hold details of all the cabins for travellers Discussions

Write discussion on Program for hold details of all the cabins for travellers
Your posts are moderated
Related Questions
The schematic of the traffic light controller is as shown in figure 1. There are three control buttons on the panel: HAZ (Hazard), LT (Left) and RT (Right). Whenever, HAZ is clicke

1.   You have been asked to write a computer program that will figure out the total of an order when given the amount of the order ($200) and a sales tax rate of five percent.  I w

1- Allocate array with 32bit 100 element 2- Prompt the user to enter the maximum or the upper bound of the random value 3- Read the value and use it generate random numbers to init

Expertsmind brings you unique solution in java assignments String Handling Series signifies a sequence of character types. It has set duration of personality sequence. Onc

Procedure-oriented programming (POP):- This is a top-down programming approach, where the problem is viewed as a sequence of tasks to be done such as calculating, printing etc. A n

I need help with making a assembly program that uses Hoffman''s coding scheme to compress a text file.

Selfcare Project:   Technology Used Strut Frame work, WAS 5.1, WPS 6.0, DB2, AJAX, Eclipse, Rational Application Developer 6 and  DB2 Selfcare is a big umbrella under whic

Expertsmind brings you unique solution in java assignments I.O streams The packages contains nearly every category you might ever need to execute feedback and resu

hello there, I making a program for the collage but I got stuck at one point, I have a timmer that moves object pnl with the pnl.left function, but I want it when it gets to end of

(a) Write a recursive procedure (digits n) that computes the number of digits in the integer n using a linear recursive process. For example, (digits 42) should return 2 and (digit