Code Monkey home page Code Monkey logo

company_challenge's Introduction

company_challenge

solution for coding challenge for company application

Challenge is as follows:

A simple hotel booking system keeps track of the rooms in a hotel. A guest can book a room for individual nights and the booking system maintains the state of these bookings. Guests are identified by their surname which, for the purposes of this exercise, can be considered unique. Rooms are identified by their room number taken from an arbitrary, potentially non-sequential set of numbers. For example, a hotel might have four rooms {101, 102, 201, 203}. The booking system may be used by a number of hotel staff at once, so must be thread-safe.

Part 1)

Implement the following interface to provide the functionality for the booking manager. Try to keep your code simple and handle errors in a sensible fashion.

public interface BookingManager {
/**
* Return true if there is no booking for the given room on the date,
* otherwise false
*/
public boolean isRoomAvailable(Integer room, Date date);
/**
* Add a booking for the given guest in the given room on the given date.
*/
public void addBooking(String guest, Integer room, Date date);
}

Example usage

Assuming a hotel with four rooms, {101, 102, 201, 203}:

BookingManager bm = // create your manager here;
Date today = java.sql.Date.valueOf("2012-03-28");
System.out.println(bm.isRoomAvailable(101, today)); // outputs true
bm.addBooking("Smith", 101, today);
System.out.println(bm.isRoomAvailable(101, today)); // outputs false

Part 2)

Good news! The hotel staff love your system. However, they find it rather tedious to check the availability of each room separately.

Copy your solution to Part 1, and modify it to implement the method below:

/**
* Return a list of all the available room numbers for the given date
*/
public Iterable<Integer> getAvailableRooms(Date date);

company_challenge's People

Contributors

takaooo avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.