/* lab3-5b.java ;; Data to represent a camera shot: ;; either a still photo or a video clip ;; A Shot is one of ;; -- Photo ;; -- Video ;; A Photo is (make-photo String Number Number Number String) (define-struct photo (name width height bytes kind)) (define river (make-photo "River" 3456 2304 3614571 "jpeg")) (define mountain (make-photo "Mountain" 2448 3264 1276114 "jpeg")) (define people (make-photo "People" 545 641 13760 "gif")) (define plt-icon (make-photo "PLT icon" 16 16 1334 "bmp")) ;; A Video is (make-video String String Number Number Boolean) (define-struct video (name kind size duration sound?)) ;; Interpretation: ;; kind of video may be either QuickTime or RealPlayer ;; size is measured in bytes ;; duration is measured in seconds ;; sound? indicated whether or not this video has sound (define beach (make-video "Beach" "QuickTime" 3614571 5 false)) (define hike (make-video "Hike" "RealPlayer" 1276114 3 false)) (define party (make-video "Party" "QuickTime" 5456434 2 true)) (define tutorial (make-video "Tutorial" "RealPlayer" 23551334 5 true)) */ /* +-------------+ | Photo | +-------------+ | String name | | int width | | int height | | int bytes | | String kind | +-------------+ */ // to represent an entry in an iPhoto collection interface Shot{ } // to represent a still photo in an iPhoto collection class Photo implements Shot{ String name; int width; int height; int bytes; String kind; Photo(String name, int width, int height, int bytes, String kind){ this.name = name; this.width = width; this.height = height; this.bytes = bytes; this.kind = kind; } } /* +-------------+ | Video | +-------------+ | String name | | int width | | int height | | int bytes | | String kind | +-------------+ */ // to represent a video clip in an iPhoto collection class Video implements Shot{ String name; String kind; int size; int duration; // in minutes boolean sound; Video(String name, String kind, int size, int duration, boolean sound){ this.name = name; this.kind = kind; this.size = size; this.duration = duration; this.sound = sound; } } // examples for the class hierachy that represents photo and video shots class Examples{ Examples (){} // (define river (make-photo "River" 3456 2304 3614571 "jpeg")) Shot river = new Photo("River", 3456, 2304, 3614571, "jpeg"); // (define mountain (make-photo "Mountain" 2448 3264 1276114 "jpeg")) Shot mountain = new Photo("Mountain", 2448, 3264, 1276114, "jpeg"); // (define people (make-photo "People" 545 641 13760 "gif")) Shot people = new Photo("People", 545, 641, 13760, "gif"); // (define plt-icon (make-photo "PLT icon" 16 16 1334 "bmp")) Shot pltIcon = new Photo("PLT icon", 16, 16, 1334, "bmp"); // (define beach (make-video "Beach" "QuickTime" 3614571 5 false)) Shot beach = new Video("Beach", "QuickTime", 3614571, 5, false); // (define hike (make-video "Hike" "RealPlayer" 1276114 3 false)) Shot hike = new Video("Hike", "RealPlayer", 1276114, 3, false); // (define party (make-video "Party" "QuickTime" 5456434 2 true)) Shot party = new Video("Party", "QuickTime", 5456434, 2, true); // (define tutorial (make-video "Tutorial" "RealPlayer" 23551334 5 true)) Shot tutorial = new Video("Tutorial", "RealPlayer", 23551334, 5, true); } /* +------------+ | Shot | +------------+ / \ --- | ------------------------- | | +-------------+ +---------------+ | Photo | | Video | +-------------+ +---------------+ | String name | | String name | | int width | | String kind | | int height | | int size | | int bytes | | int duration | | String kind | | boolean sound | +-------------+ +---------------+ */