// APS101, Winter 2009: Lecture 8 (Jan. 26) // // Review: last week we customized a JFrame class // We wrote OurJFrame.java // // Recall: // access modifier: public, private // public: useable by anyone, anywhere // private: only useable within a class // OurJFrame: doubleWidth(), flip(), getOurTitle() // We also wrote 3 constructors // We learned how to use "this" to write constructor methods // // for practice, we wrote a new method called doubleDouble(), // which calls method doubleWidth() twice. OurJFrame ow = new OurJFrame(); ow.doubleDouble() ow.getWidth() // Today you'll be writing your own class from scratch, // as opposed to just customizing. // // first, we wrote 2 constructors BankAccount ba = new BankAccount("John", "Smith", 100000.0, true, 1234); ba BankAccount ba2 = new BankAccount("Bob", "Jones", 1235); BankAccount ba3 = ba; ba3 == ba // then, we wrote the getBalance() method BankAccount ba2 = new BankAccount("Bob", "Jones", 1235); ba2.getBalance() BankAccount ba = new BankAccount("John", "Smith", 100000.0, true, 1234); ba.getBalance() // then, we wrote the withdraw method() BankAccount ba = new BankAccount("John", "Smith", 100000.0, true, 1234); ba.withdraw(500) ba.getBalance() ba.getBalance(99500) ba.withdraw(99500.0) ba.getBalance() ba.withdraw(1) ba.getBalance() ba.withdraw(-1) ba.getBalance() // then, we wrote the deposit method int x = 5; x += 6; x BankAccount ba2 = new BankAccount("Bob", "Jones", 1235); ba2.getBalance() ba2.deposit(100000) ba2.getBalance() int x = 5; x =+ 6 x // finally, we wrote the isEqual(BankAccount) method BankAccount ba2 = new BankAccount("Bob", "Jones", 1235); BankAccount ba1 = new BankAccount("Bob", "Smith", 1235); ba1.isEqual(ba2) BankAccount ba3 = new BankAccount("Bob", "Smith", 1234); ba1.isEqual(ba3)