diff options
Diffstat (limited to 'oop/09-polymorphism/CustomerApp.java')
| -rw-r--r-- | oop/09-polymorphism/CustomerApp.java | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/oop/09-polymorphism/CustomerApp.java b/oop/09-polymorphism/CustomerApp.java deleted file mode 100644 index 79e1c31..0000000 --- a/oop/09-polymorphism/CustomerApp.java +++ /dev/null @@ -1,46 +0,0 @@ -import java.util.ArrayList; -import java.util.Date; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -public class CustomerApp { - - /** - * @param args - */ - public static void main(String[] args) { - List list = new LinkedList(); - - Customer c = new Customer(1, "Kamal", "Nugegoda", "123456", "654321"); - list.add(c); - - c = new Customer(2, "Nimal", "Colombo", "2234343", "2343433"); - list.add(c); - - c = new PremiumCustomer(1, "Sunil", "Kohuwala", "23443434", "9888234", - "a", "Give him whatever he ask"); - list.add(c); - - list.add(new Date()); - - Iterator itr = list.iterator(); - - CustomerDetailsFormatter formatter = new CustomerDetailsFormatter(); - - while (itr.hasNext()) { - Customer customer = (Customer) itr.next(); // Convert "java.lang.Object" to "Customer" - String formattedString = formatter.getFormattedDescription(customer); - System.out.println(formattedString); - } - - /* - Account a1 = new SavingsAccount(); // Coercion (implicit conversion) - a1.accountClassMethod(); - - Account a1 = someMethod(); - SavingsAccount sa = (SavingsAccount) a1; // Down casting - sa.savingsAccountClassMethod(); - */ - } -} |
