1 // WISEObject.java 2 // 3 // Ethan Bolker 4 // May, 2004 for cs110 final project 5 6 import java.util.*; 7 8 /** 9 * An object in the WISE system (Student, Course, Professor) 10 */ 11 public abstract class WISEObject 12 { 13 // everything has a name 14 private String name; 15 16 // Students and Professors have lists of Courses, 17 // Courses have lists of Students. 18 private WISEList list; 19 20 /** 21 * Construct a new WISEObject. 22 */ 23 public WISEObject( String name ) 24 { 25 this.name = name; 26 } 27 28 public String getName() 29 { 30 return name; 31 } 32 33 public WISEList getList() 34 { 35 return list; 36 } 37 38 public void setList( WISEList list ) 39 { 40 this.list = list; 41 } 42 43 // override this method in Course.java 44 /** 45 * Can a Professor or a Student use a Course at this time? 46 */ 47 public boolean isAvailable( TimeOfDay tod ) 48 { 49 Iterator i = list.iterator(); 50 while (i.hasNext()) { 51 Course course = (Course)i.next(); 52 if (tod.equals(course.getTimeOfDay())) { 53 return false; 54 } 55 } 56 return true; 57 } 58 } 59 60 61 62 63 64