⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pos.java

📁 This project developed in java leads us to realize a flight reservation system in order to emulate d
💻 JAVA
字号:
/* * Pos.java * The package system contains the different class allowing to create and to select the object to store in the database. */package reservation.system;import java.io.Serializable;/** * This class hold Pos structure. This object define the dimention of a {@link reservation.system.Flight} and the seat for a <CODE> {@link reservation.system.Person}</CODE>. * @author Texier Mathieu and Frederic Bidon */public class Pos extends Object implements Cloneable, Serializable {    /**     * Construct a <CODE>Pos</CODE> object.     * @param row The number of <CODE>rows</CODE> for a {@link reservation.system.Flight} and the row of the seat for a {@link reservation.system.Person}.     * @param col The length of a <CODE>row</CODE> for a {@link reservation.system.Flight} and the col of the seat for a {@link reservation.system.Person}.     * @throws Exception When value dosn't make sense, this exception is thrown     */    public Pos (short row, short col) throws Exception {        this.row = row;        this.col = col;        _check ();    }        /**     * Return The number of <CODE>rows</CODE> for a {@link reservation.system.Flight} and the row of the seat for a {@link reservation.system.Person}.     * @return the row     * @throws Exception when the invariant is violated     */    public short getRow () throws Exception {        _check ();        return row;    }         /**      * Return The length of a <CODE>row</CODE> for a {@link reservation.system.Flight} and the col of the seat for a {@link reservation.system.Person}.      * @return the col      * @throws Exception when the invariant is violated      */    public short getCol () throws Exception {        _check ();        return col;    }         /**     * Overide equals     * @return <CODE>true</CODE> if this object is the same as the obj argument;     * <CODE>false</CODE> otherwise     * @param anObject <CODE>anObject</CODE> - the reference object with which to compare     */       public boolean equals (Object anObject) {        if (anObject != null && anObject instanceof Pos) {            Pos pos = (Pos) anObject;            return ((this.row == pos.row) && (this.col == pos.col));        }        else            return false;    }         /**     * Returns a string representation of this <CODE>Flight</CODE> object. This method     * is intended to be used only for debugging purposes, and the content and format     * of the returned string may vary between implementations. The returned string may     * be empty but may not be <CODE>null</CODE>     * @return a string representation of this <CODE>Pos</CODE> object.     */       public String toString () {        return "("+row+","+col+")";    }        /**     * Creates and returns a copy of this object.     * @return a copy of this <CODE>Pos</CODE> object     * @throws CloneNotSupportedException if the object's class does not support the <CODE>Cloneable</CODE> interface.     */        protected Object clone () throws CloneNotSupportedException {        try {            return new Pos (row, col);        } catch (Exception e){System.err.println (e);return null;}    }         /**     * Verify invariants :     * <PRE>     * - dimension > 0     * </PRE>     * @throws Exception if the invariant is violated     */       public void _check () throws Exception {        if (row <= 0 || col <= 0)            throw new Exception ("Position has a negative or null value");    }        private short row;    private short col;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -