/******************************************************************* Copyright (c) 2001-2007 Apprisant Technologies Inc. All rights reserved. Apprisant Technologies permits non-exclusive royalty free use, copying and modification of this demo program source code for the purposes of evaluating the Apprisant Toolkit or building applications that use it. This software and documentation is provided "AS IS". APPRISANT TECHNOLOGIES DISCLAIMS ANY REPRESENTATIONS AND WARRANTIES, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS OF THIS PRODUCT FOR ANY PARTICULAR PURPOSE. APPRISANT TECHNOLOGIES SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY ANY PARTY, INCLUDING LOST PROFITS, ARISING FROM THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ITS DERIVATIONS. ********************************************************************/ package camp; /* Data object class for the Camp demo. The key is the site number. Other attributes are hookup type, site length, whether the site is reserved, and if it is reserved by the current user. */ public class Site { // Attribute names public static final String P_STATE = "state"; public static final String P_HOOKUP = "hookup"; public static final String P_LENGTH = "length"; // Hookup values public static enum Hookup { NONE, ELECTRIC, FULL } // State values public static final String VACANT = "vacant"; public static final String RESERVED_OTHER = "reserved_other"; public static final String RESERVED_USER = "reserved_user"; String siteNum; Hookup hookup; int length; boolean reserved = false; boolean reservedByUser = false; public Site (String siteNum, Hookup hookup, int length, boolean reserved) { this.siteNum = siteNum; this.hookup = hookup; this.length = length; this.reserved = reserved; } public String getKey () { return siteNum; } public Hookup getHookup() { return hookup; } public int getLength() { return length; } public String getState() { return (reserved ? (reservedByUser ? RESERVED_USER : RESERVED_OTHER) : VACANT); } public void reserve() { if (! reserved) { this.reserved = true; this.reservedByUser = true; } } public void cancel() { if (reserved && reservedByUser) { this.reserved = false; this.reservedByUser = false; } } }