//we had quiz1 and discussions //look at the completed BankAccount code from Jan24 /* -----> static variables (also called Class variables): example: see totalNumAccounts variable in BankAccount shared by all objects if public, can be accessed either by classname.variblename or objectname.variablename if private, we usually have getter/setter methods like other variables if one object changes the value of a static variable, all other objects see the updated value (remember there is only one variable share by all) -----> static method (also called Class methods): methods that only accesses the static data in class usually called by classname.methodname(...) but can also use objectname.methodname(...) they don't have access to non-static data, why? Example: see getTotalNumAccounts() in BankAccount exercise: try to change or access a non-static variable balance or lastName in this method, why doesn't the program compile? -------> Constants: cannot be changed after initialized used to avoid "magic numbers"! instead of using number 5, e.g., you define a constant called WORK_DAYS and use it instead of number 5. (easier to read the code, and modify it afterwards). syntax in java: we use final keyword style issue: we use all capital letters, and separate words with _ example: public static DEPOSIT_FEE = 3.5; note in assignment 1, you need to define a couple of constant in the Airport class, and use them in your code. -----> Testing code using JUnit See BankAccountTester from Jan 24, also RunwayTester from A1 Here is the general instructions to create a test class for a class called MyClass: 1. we we extend the TestCase class and call it MyClassClassTester e.g. import junit.framework.TestCase; public class MyClassTester extends TestCase { .... } 2. for every public method of our class (including constructors) we write a 'tester method' * a tester method for method say "m1" has the following syntax: public void testM1(){ //body } where in the body you usually create some objects and call the m1 method. And then check whether the expected values are returned We do this by using "assertTrue"/"assertFalse" or in general "assertEquals(...)" see examples from A1 and BankAccountTester Important: don't forget to put comments for every test case! exercise: complete the testWithdraw method in BankAccountTester */