001    package videoautomat;
002    import java.util.Date;
003    
004    import log.LogEntry;
005    import sale.Shop;
006    /**
007     * This class implements a <code>LogEntry</code> that describes the rent or hand back of a video.
008     */
009    public class LogEntryVideo extends LogEntry {
010    
011            /**
012             * ID for Serialization.
013             */
014            private static final long serialVersionUID = 1373171045602909791L;
015    
016            /*
017             * The name of the user who rented or handed back a video.
018             */
019            private String user_ID;
020    
021            /*
022             * The name of the relevant video.
023             */
024            private String video_name;
025    
026            /*
027             * True if this entry logs a rent event, otherwise false.
028             */
029            private boolean rented;
030    
031            /*
032             * The date of logging.
033             */
034            private Date date;
035    
036            /**
037             * Constructs a new <code>LogEntryVideo</code> by the given params and the current date.
038             * 
039             * @param user_ID
040             *                  the ID of the relevant user
041             * @param video
042             *                  the name of the relevant video
043             * @param rented
044             *                  choose true if this entry should log a rent event, otherwise false
045             */
046            public LogEntryVideo(String user_ID, String video, boolean rented) {
047                    this.user_ID = user_ID;
048                    this.video_name = video;
049                    this.rented = rented;
050                    date = (Date) Shop.getTheShop().getTimer().getTime();
051            }
052    
053            /**
054             * @return a <code>String</code> representing whether who has rented or who gave back which video.
055             * 
056             * @see java.lang.Object#toString()
057             */
058            public String toString() {
059                    String s = " gave back ";
060                    if (rented)
061                            s = " has rented ";
062                    return ("The user " + user_ID + s + video_name);
063            }
064    
065            /**
066             * @return the date of logging.
067             * 
068             * @see log.LogEntry#getLogDate()
069             */
070            public Date getLogDate() {
071                    return date;
072            }
073    }