001package myhw1;
002
003// TODO: complete the methods
004/**
005 * Immutable Data Class for video objects.
006 * Comprises a triple: title, year, director.
007 *
008 * <p><b>Class Type:</b> Immutable Data Class</p>
009 * <p><b>Object Invariant:</b></p>
010 *   Title is non-null, no leading or final spaces, not empty string.
011 * <p><b>Object Invariant:</b></p>
012 *   Year is greater than 1800, less than 5000.
013 * <p><b>Object Invariant:</b></p>
014 *   Director is non-null, no leading or final spaces, not empty string.
015 */
016final class VideoObj implements Comparable<VideoObj> {
017        /** <p><b>Invariant:</b> non-null, no leading or final spaces, not empty string </p>*/
018        private final String title;
019        /** <p><b>Invariant:</b> greater than 1800, less than 5000 </p>*/
020        private final int    year;
021        /** <p><b>Invariant:</b> non-null, no leading or final spaces, not empty string </p>*/
022        private final String director;
023
024        /**
025         * Initialize all object attributes.
026         * Title and director are "trimmed" to remove leading and final space.
027         * @throws IllegalArgumentException if any object invariant is violated.
028         */
029        VideoObj(String title, int year, String director) {
030                // TODO
031                this.title = null;
032                this.year = 0;
033                this.director = null;
034                 
035        }
036
037        /**
038         * Return the value of the attribute.
039         */
040        public String director() {
041                // TODO
042                return "director";
043        }
044
045        /**
046         * Return the value of the attribute.
047         */
048        public String title() {
049                // TODO
050                return "title";
051        }
052
053        /**
054         * Return the value of the attribute.
055         */
056        public int year() {
057                // TODO
058                return -1;
059        }
060
061        /**
062         * Compare the attributes of this object with those of thatObject.
063         * @param thatObject the Object to be compared.
064         * @return deep equality test between this and thatObject.
065         */
066        public boolean equals(Object thatObject) {
067                // TODO
068                return false;
069        }
070
071        /**
072         * Return a hash code value for this object using the algorithm from Bloch:
073         * fields are added in the following order: title, year, director.
074         */
075        public int hashCode() {
076                // TODO
077                return -1;
078        }
079
080        /**
081         * Compares the attributes of this object with those of thatObject, in
082         * the following order: title, year, director.
083         * @param that the VideoObj to be compared.
084         * @return a negative integer, zero, or a positive integer as this
085         *  object is less than, equal to, or greater than that object.
086         */
087        public int compareTo(VideoObj that) {
088                // TODO
089                return -1;
090        }
091
092        /**
093         * Return a string representation of the object in the following format:
094         * <code>"title (year) : director"</code>.
095         */
096        public String toString() {
097                // TODO
098                return "El Mariachi (1996) : Rodriguez";
099        }
100}