import java.lang.*; import java.io.*; import edu.neu.ccs.demeter.dj.*; import java.util.*; import edu.neu.ccs.demeter.*; class Bank { protected BusinessUnit_List businessunit_list; public BusinessUnit_List get_businessunit_list() { return businessunit_list; } public void set_businessunit_list(BusinessUnit_List new_businessunit_list) { businessunit_list = new_businessunit_list; } public Bank() { super(); } public Bank(BusinessUnit_List businessunit_list) { super(); set_businessunit_list(businessunit_list); } public static Bank parse(java.io.Reader in) throws ParseException { return new Parser(in)._Bank(); } public static Bank parse(java.io.InputStream in) throws ParseException { return new Parser(in)._Bank(); } public static Bank parse(String s) { try { return parse(new java.io.StringReader(s)); } catch (ParseException e) { throw new RuntimeException(e.toString()); } } public void addBusinessUnit() { /* This function will add a new business unit to the bank.*/ Index index; //the index of the new unit Country country; //the country of the new unit Location location; //the location of the new unit BusinessUnit newBU; //the unit created that will be added to the bank try { location = Location.prompt("Enter location of new unit"); country = Country.prompt("Enter country of new unit"); //generate index if (get_businessunit_list() == null) index = new Index(1); else index = new Index(get_businessunit_list().size() + 1); //add the new business unit newBU = new BusinessUnit(index, country, location, new Party_List()); businessunit_list.addElement(newBU); //inform the user that add was successful System.out.println("Business unit "); newBU.viewUnit(); System.out.println("has been added"); } catch (Exception e) { System.out.print ("Error in addBusinessUnit: " + e.toString());} } public void modifyBusinessUnit() { /* This function will allow the user to modify business unit information */ BusinessUnit changeMe; //the unit that needs to be modified Index changeMeId; //index of the unit we will modify changeMeId = Index.prompt("Enter the index of the unit you wish to modify: "); changeMe = get_businessunit_list().findBusinessUnit(changeMeId, true); if (changeMe != null) changeMe.modify(); } void print() { PrintVisitor v0 = new PrintVisitor(); v0.start(); __trav_print(v0); v0.finish(); } void display() { DisplayVisitor v0 = new DisplayVisitor(); v0.start(); __trav_display(v0); v0.finish(); } public void viewUnits() { get_businessunit_list().viewUnits(); } public Party findParty(PartyId findMeId, boolean display) { /* This function will look for a party based on ID. input: findMeId - the PartyId of the party we are looking for display - If true, the party will be displayed to the screen output: the Party object with PartyId */ Party currP = null; //current party in the enumeration BusinessUnit currBU; //current Business Unit in the enumeration boolean found = false; //flag to know when to stop looking java.util.Enumeration p_en; //party enumeration java.util.Enumeration bul_en = this.get_businessunit_list().elements(); //search business units while (bul_en.hasMoreElements() && !found) { currBU = (BusinessUnit) bul_en.nextElement(); p_en = currBU.get_party_list().elements(); //search parties while (p_en.hasMoreElements() && !found) { currP = (Party) p_en.nextElement(); found = currP.get_partyid().get_partyId() == findMeId.get_partyId(); } } if (!found) { System.out.println("Party " + findMeId.get_partyId() + " could not be found"); currP = null; } else if (display) currP.viewParty(); return currP; } void universal_trv0_bef(UniversalVisitor _v_) { ((UniversalVisitor) _v_).before(this); } void universal_trv0_aft(UniversalVisitor _v_) { ((UniversalVisitor) _v_).after(this); } void universal_trv0(UniversalVisitor _v_) { universal_trv0_bef(_v_); ((UniversalVisitor) _v_).before_businessunit_list(this, businessunit_list); businessunit_list.universal_trv0(_v_); ((UniversalVisitor) _v_).after_businessunit_list(this, businessunit_list); universal_trv0_aft(_v_); } public void everything(PrintVisitor __v0) { everything_Bank_trv(__v0); } void everything_Bank_trv_bef(PrintVisitor __v0) { ((UniversalVisitor) __v0).before(this); } void everything_Bank_trv_aft(PrintVisitor __v0) { ((UniversalVisitor) __v0).after(this); } void everything_Bank_trv(PrintVisitor __v0) { everything_Bank_trv_bef(__v0); ((UniversalVisitor) __v0).before_businessunit_list(this, businessunit_list); businessunit_list.everything_Bank_trv(__v0); ((UniversalVisitor) __v0).after_businessunit_list(this, businessunit_list); everything_Bank_trv_aft(__v0); } public void __trav_print(PrintVisitor __v0) { __trav_print_Bank_trv(__v0); } void __trav_print_Bank_trv_bef(PrintVisitor __v0) { ((UniversalVisitor) __v0).before(this); } void __trav_print_Bank_trv_aft(PrintVisitor __v0) { ((UniversalVisitor) __v0).after(this); } void __trav_print_Bank_trv(PrintVisitor __v0) { __trav_print_Bank_trv_bef(__v0); ((UniversalVisitor) __v0).before_businessunit_list(this, businessunit_list); businessunit_list.__trav_print_Bank_trv(__v0); ((UniversalVisitor) __v0).after_businessunit_list(this, businessunit_list); __trav_print_Bank_trv_aft(__v0); } public void __trav_display(DisplayVisitor __v0) { __trav_display_Bank_trv(__v0); } void __trav_display_Bank_trv_bef(DisplayVisitor __v0) { ((DisplayVisitor) __v0).before(this); } void __trav_display_Bank_trv_aft(DisplayVisitor __v0) { ((DisplayVisitor) __v0).after(this); } void __trav_display_Bank_trv(DisplayVisitor __v0) { __trav_display_Bank_trv_bef(__v0); ((DisplayVisitor) __v0).before_businessunit_list(this, businessunit_list); businessunit_list.__trav_display_Bank_trv(__v0); ((UniversalVisitor) __v0).after_businessunit_list(this, businessunit_list); __trav_display_Bank_trv_aft(__v0); } }