import java.awt.*; // Java GUI classes import java.applet.*; public abstract class DomainLogic { // super class, abstract => must be subclassed // protected variables so subclasses can access protected TextArea textArea1; // print to textArea1 protected static Account account = null; // current account, static to share among subclasses protected static Investor investor = null; // current investor, static also public DomainLogic(TextArea textArea1) { this.textArea1 = textArea1; } // protected methods so subclasses can access protected boolean chkLogin() { // reports and trading can only occur after a login boolean OK = false; if (investor==null) textArea1.append("Must login first.\n"); else if (account==null) textArea1.append("Must have an account.\n"); else OK = true; return OK; } // helper methods for text processing protected double toDouble(String s) { Double d = new Double(0.0); try { d = Double.valueOf(s); } catch(Exception e) {return 0.0;} return d.doubleValue(); } protected int toInt(String s) { Integer i = new Integer(0); try { i = Integer.valueOf(s); } catch(Exception e) {return 0;} return i.intValue(); } protected String pad(String s, int width, String padChar, boolean padLeft) { for (int i=s.length()+1; i<=width; i++) if (padLeft) s = padChar + s; else s = s + padChar; return s; } }