import java.lang.*; import java.io.*; import edu.neu.ccs.demeter.dj.*; import java.util.*; import edu.neu.ccs.demeter.*; class Contract_List implements java.util.Enumeration { protected Nonempty_Contract_List first; public Nonempty_Contract_List get_first() { return first; } public void set_first(Nonempty_Contract_List new_first) { first = new_first; } public Contract_List() { super(); } public Contract_List(Nonempty_Contract_List first) { super(); set_first(first); } public static Contract_List parse(java.io.Reader in) throws ParseException { return new Parser(in)._Contract_List(); } public static Contract_List parse(java.io.InputStream in) throws ParseException { return new Parser(in)._Contract_List(); } public static Contract_List parse(String s) { try { return parse(new java.io.StringReader(s)); } catch (ParseException e) { throw new RuntimeException(e.toString()); } } public void viewContracts() { /* This function will print all of the contracts in the list, skipping over the portfolio information */ Contract tempContract; java.util.Enumeration en = this.elements(); System.out.println(Main.divider); while (en.hasMoreElements()){ tempContract = (Contract) en.nextElement(); tempContract.viewContract(); } } public Contract findContract(Index here, boolean display) { /* finds a contract in this list input: here - the index of the contract we're looking for display - if true, the contract is displayed to the screen output: the existing Contract object or null */ Contract currContract = null; //current Contract in the enumeration boolean found = false; //flag to know when to stop looking java.util.Enumeration en = this.elements(); //search contract list while (en.hasMoreElements() && !found) { currContract = (Contract) en.nextElement(); found = currContract.get_index().get_index() == here.get_index(); } if (!found){ System.out.println("Contract at " + here.get_index() + " could not be found"); currContract = null; } else if (display) currContract.viewContract(); return currContract; } 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_); if (first != null) { ((UniversalVisitor) _v_).before_first(this, first); first.universal_trv0(_v_); ((UniversalVisitor) _v_).after_first(this, first); } universal_trv0_aft(_v_); } void everything_Bank_trv_bef(PrintVisitor __v0) { ((PrintVisitor) __v0).before(this); } void everything_Bank_trv_aft(PrintVisitor __v0) { ((PrintVisitor) __v0).after(this); } void everything_Bank_trv(PrintVisitor __v0) { everything_Bank_trv_bef(__v0); if (first != null) { ((UniversalVisitor) __v0).before_first(this, first); first.everything_Bank_trv(__v0); ((UniversalVisitor) __v0).after_first(this, first); } everything_Bank_trv_aft(__v0); } void __trav_print_Bank_trv_bef(PrintVisitor __v0) { ((PrintVisitor) __v0).before(this); } void __trav_print_Bank_trv_aft(PrintVisitor __v0) { ((PrintVisitor) __v0).after(this); } void __trav_print_Bank_trv(PrintVisitor __v0) { __trav_print_Bank_trv_bef(__v0); if (first != null) { ((UniversalVisitor) __v0).before_first(this, first); first.__trav_print_Bank_trv(__v0); ((UniversalVisitor) __v0).after_first(this, first); } __trav_print_Bank_trv_aft(__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); if (first != null) { ((DisplayVisitor) __v0).before_first(this, first); first.__trav_display_Bank_trv(__v0); ((UniversalVisitor) __v0).after_first(this, first); } __trav_display_Bank_trv_aft(__v0); } void __trav_viewAccount_Account_trv_bef(PrintVisitor __v0) { ((PrintVisitor) __v0).before(this); } void __trav_viewAccount_Account_trv_aft(PrintVisitor __v0) { ((PrintVisitor) __v0).after(this); } void __trav_viewAccount_Account_trv(PrintVisitor __v0) { __trav_viewAccount_Account_trv_bef(__v0); if (first != null) { ((UniversalVisitor) __v0).before_first(this, first); first.__trav_viewAccount_Account_trv(__v0); ((UniversalVisitor) __v0).after_first(this, first); } __trav_viewAccount_Account_trv_aft(__v0); } private Nonempty_Contract_List tail; public void addElement(Contract e) { checktail(); if (tail == null) { first = new Nonempty_Contract_List(e,null); tail = first; } else { tail.set_next(new Nonempty_Contract_List(e,null)); tail = tail.get_next(); } } public void push(Contract e) { first = new Nonempty_Contract_List(e,first); } public java.util.Enumeration elements() { return new Contract_List(first); } public int size() { int i= 0; for (java.util.Enumeration e=elements(); e.hasMoreElements(); i++) e.nextElement(); return i; } public boolean isEmpty() { return (first == null); } public boolean hasMoreElements() { return (first != null); } public Object nextElement() { Contract car = first.get_it(); first = first.get_next(); return (Object) car; } private void checktail() { if (tail == null && first != null) { tail = first; while (tail.get_next() != null) tail = tail.get_next(); } } public boolean contains(Contract e) { java.util.Enumeration en = this.elements(); while (en.hasMoreElements()) if (e.equals((Contract) en.nextElement())) return true; return false; } }