import java.lang.*; import java.io.*; import edu.neu.ccs.demeter.dj.*; import java.util.*; import edu.neu.ccs.demeter.*; abstract class Posting { protected Amount amount; public Amount get_amount() { return amount; } public void set_amount(Amount new_amount) { amount = new_amount; } protected Date date; public Date get_date() { return date; } public void set_date(Date new_date) { date = new_date; } public Posting() { super(); } public Posting(Amount amount, Date date) { super(); set_amount(amount); set_date(date); } private static HashMap subclassMap = null; //holds objects of all subclasses of posting private static void setUpSubclassMap() { /* populates the subclass table */ subclassMap = new HashMap(); subclassMap.put("+", new Credit()); subclassMap.put("-", new Debit()); } public static Posting prompt(String prompt) { /* This function will find an posting given by the user input : prompt - string used to prompt the user output: a new posting described by the user */ Posting returnPosting; char postType = Main.promptChar("Enter + for credit or - for debit"); Amount amount = Amount.prompt("how much"); Date date = Date.prompt("enter posting date"); if (postType == '+') returnPosting = new Credit(amount, date); else returnPosting = new Debit(amount, date); return returnPosting; } void viewPosting() { PrintVisitor v0 = new PrintVisitor(); v0.start(); __trav_viewPosting(v0); v0.finish(); } 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_) { ((UniversalVisitor) _v_).before_amount(this, amount); amount.universal_trv0(_v_); ((UniversalVisitor) _v_).after_amount(this, amount); ((UniversalVisitor) _v_).before_date(this, date); date.universal_trv0(_v_); ((UniversalVisitor) _v_).after_date(this, date); } 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) { ((UniversalVisitor) __v0).before_amount(this, amount); amount.everything_Bank_trv(__v0); ((UniversalVisitor) __v0).after_amount(this, amount); ((UniversalVisitor) __v0).before_date(this, date); date.everything_Bank_trv(__v0); ((UniversalVisitor) __v0).after_date(this, date); } 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) { ((UniversalVisitor) __v0).before_amount(this, amount); amount.__trav_print_Bank_trv(__v0); ((UniversalVisitor) __v0).after_amount(this, amount); ((UniversalVisitor) __v0).before_date(this, date); date.__trav_print_Bank_trv(__v0); ((UniversalVisitor) __v0).after_date(this, date); } void __trav_display_Bank_trv_bef(DisplayVisitor __v0) { ((UniversalVisitor) __v0).before(this); } void __trav_display_Bank_trv_aft(DisplayVisitor __v0) { ((UniversalVisitor) __v0).after(this); } void __trav_display_Bank_trv(DisplayVisitor __v0) { ((DisplayVisitor) __v0).before_amount(this, amount); amount.__trav_display_Bank_trv(__v0); ((UniversalVisitor) __v0).after_amount(this, amount); ((DisplayVisitor) __v0).before_date(this, date); date.__trav_display_Bank_trv(__v0); ((UniversalVisitor) __v0).after_date(this, date); } public void __trav_viewPosting(PrintVisitor __v0) { __trav_viewPosting_Posting_trv(__v0); } void __trav_viewPosting_Posting_trv_bef(PrintVisitor __v0) { ((UniversalVisitor) __v0).before(this); } void __trav_viewPosting_Posting_trv_aft(PrintVisitor __v0) { ((UniversalVisitor) __v0).after(this); } void __trav_viewPosting_Posting_trv(PrintVisitor __v0) { ((UniversalVisitor) __v0).before_amount(this, amount); amount.__trav_viewPosting_Posting_trv(__v0); ((UniversalVisitor) __v0).after_amount(this, amount); ((UniversalVisitor) __v0).before_date(this, date); date.__trav_viewPosting_Posting_trv(__v0); ((UniversalVisitor) __v0).after_date(this, date); } }