/* * Wrapper class seat holding a boolean value * for a seat in a (movie) theatre. * * Carsten Butz, September 2002 */ public class Seat{ /* * Instance variable: */ private boolean occupied; /* * Constructors: */ Seat(){}; Seat(boolean o){ occupied = o; } /* * Instance methods: */ public boolean isFree(){ return !this.occupied; } public boolean isOccupied(){ return this.occupied; // keyword this isn't needed here } public boolean occupy(){ if(occupied) return false; else { occupied = true; return true; } } public boolean release(){ if(!isOccupied()) return false; else { occupied = false; return true; } } }