import java.beans.*; import utilities.beans.*; public class PrimitiveGames extends Object { //------------------------------------------------------------------- // main() entry point //------------------------------------------------------------------- public static void main (String[] args) { new PrimitiveGames(); } //------------------------------------------------------------------- // PrimitiveGames Constructor //------------------------------------------------------------------- public PrimitiveGames() { Country valuable; SuperPower a,b,c; // create one mortal country and 3 superpowers valuable = (Country) BeansKit.newBean("Country"); a = (SuperPower) BeansKit.newBean("SuperPower"); b = (SuperPower) BeansKit.newBean("SuperPower"); c = (SuperPower) BeansKit.newBean("SuperPower"); // give each country its attributes valuable.setCountryName("Kuwait"); try { valuable.setCountryStatus("Independent"); } catch (PropertyVetoException impossibleAtThisStage) { System.out.println("Caught impossible PropertyVetoException!"); System.exit(10); } a.setCountryName("Britain"); a.setArsenalSize(600000); b.setCountryName("France"); b.setArsenalSize(3000000); c.setCountryName("China"); c.setArsenalSize(12000000); // let all superpowers keep a close watch on mortal country valuable.addVetoableChangeListener(a); valuable.addVetoableChangeListener(b); valuable.addVetoableChangeListener(c); System.out.println(""); // and now the moment of truth.. // Kuwait wants to become an ally of China try { System.out.println("Attempting to have Kuwait become an ally of China\n"); valuable.setCountryStatus("ally of China"); } catch (PropertyVetoException notAcceptable) { System.out.println(""); System.out.println("Kuwait not allowed to change status because:"); System.out.println(notAcceptable); } } } // End of Class PrimitiveGames