1 import org.ozoneDB.OzoneObject; 2 import java.util.*; 3 4 public class GarageImpl extends OzoneObject implements Garage { 5 6 10 final static long serialVersionUID = 1L; 11 12 private Hashtable cars; 13 14 public GarageImpl() { 15 cars = new Hashtable(); 16 } 17 18 public void addCar_update( String name, int yearOfConst ) throws Exception { 19 Car car = (Car)database().createObject( CarImpl.class.getName() ); 20 car.setName( name ); 21 car.setYearOfConst( yearOfConst ); 22 cars.put( car.name(), car ); 23 } 24 25 public Car carForName( String name ) { 26 return (Car)cars.get( name ); 27 } 28 29 public Car removeCar_update( String name ) { 30 return (Car)cars.remove( name ); 31 } 32 33 public Vector oldtimers() { 34 Vector result = new Vector(); 35 for (Enumeration e=cars.elements(); e.hasMoreElements(); ) { 36 Car car = (Car)e.nextElement(); 37 if (car.age() >= 20) { 38 result.add( car ); 39 } 40 } 41 return result; 42 } 43 44 public void onDelete() { 45 for (Enumeration e=cars.elements(); e.hasMoreElements(); ) { 46 Car car = (Car)e.nextElement(); 47 database().deleteObject( car ); 48 } 49 } 50 } 51 | Popular Tags |