//14.6 // To describe a Gallery interface Gallery { int timeToDownload(int speed); boolean smallerThan(int bytes); boolean sameName(String filename); } // To describe am image file class Image implements Gallery { String name; int size; int height; int width; String quality; Image(String name, int size, int height, int width, String quality) { this.name = name; this.size = size; this.height = height; this.width = width; this.quality = quality; } //Determines the time ti will taek to download this file at the given speed int timeToDownload(int speed){ return this.size/speed; } //Determines if this file is smaller than the given maximum size boolean smallerThan(int bytes){ if(this.size < bytes) return true; else return false; } //Determines if the name of this file is the same as the given name boolean sameName(String filename){ if(this.name.equals(filename)) return true; else return false; } } // To describe a text file class Text implements Gallery { String name; int size; int lines; Text(String name, int size, int lines) { this.name = name; this.size = size; this.lines = lines; } //To determine the time needed to download this file at the given speed int timeToDownload(int speed){ return this.size/speed; } //To determine if this file is smaller than the given maximum size boolean smallerThan(int bytes){ if(this.size < bytes) return true; else return false; } //To determine if this file has the same name as the given filename boolean sameName(String filename){ if(this.name.equals(filename)) return true; else return false; } } // To describe a sound file class Sound implements Gallery { String name; int size; int seconds; Sound(String name, int size, int seconds) { this.name = name; this.size = size; this.seconds = seconds; } //To determine the time needed to donwload the file at the given speed int timeToDownload(int speed){ return this.size/speed; } //To determine if this file is smaller than the given maximum boolean smallerThan(int bytes) { if(this.size < bytes) return true; else return false; } //To determine if this file has the same name as the given filename boolean sameName(String filename){ if(this.name.equals(filename)) return true; else return false; } } class Examples{ Examples(){} Image img1 = new Image("Dog", 2345, 200, 300, "Hi"); Sound mp3a = new Sound("Low Rider", 4560, 150); Text txt1 = new Text("Words", 2424, 45); boolean t1 = (check this.img1.timeToDownload(5) expect 469); boolean t2 = (check this.img1.smallerThan(8756) expect true); boolean t3 = (check this.img1.sameName("Dog") expect true); boolean t4 = (check this.mp3a.timeToDownload(10) expect 456); boolean t5 = (check this.mp3a.smallerThan(2341) expect false); boolean t6 = (check this.mp3a.sameName("Low Rider") expect true); boolean t7 = (check this.txt1.timeToDownload(12) expect 202); boolean t8 = (check this.txt1.smallerThan(3535) expect true); boolean t9 = (check this.txt1.sameName("Not Right") expect false); }