summaryrefslogtreecommitdiff
path: root/oop/09-polymorphism
diff options
context:
space:
mode:
authorKamal Wickramanayake <kamal@inbox.lk>2026-02-22 19:43:58 +0530
committerKamal Wickramanayake <kamal@inbox.lk>2026-02-22 19:43:58 +0530
commitbaaba4a281b7d54e6b5d7767989c303b854b6932 (patch)
tree16201b64e9c8f20d7fa394c715f4ca5df51e9e08 /oop/09-polymorphism
parentae4cf7c9f0a0b90d02166b43402e67b7d4ad4dca (diff)
Directory rename
Diffstat (limited to 'oop/09-polymorphism')
-rw-r--r--oop/09-polymorphism/.gitignore1
-rw-r--r--oop/09-polymorphism/Customer.java60
-rw-r--r--oop/09-polymorphism/CustomerApp.java46
-rw-r--r--oop/09-polymorphism/CustomerDetailsFormatter.java17
-rw-r--r--oop/09-polymorphism/PremiumCustomer.java43
5 files changed, 0 insertions, 167 deletions
diff --git a/oop/09-polymorphism/.gitignore b/oop/09-polymorphism/.gitignore
deleted file mode 100644
index 6b468b6..0000000
--- a/oop/09-polymorphism/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.class
diff --git a/oop/09-polymorphism/Customer.java b/oop/09-polymorphism/Customer.java
deleted file mode 100644
index 56b0f7b..0000000
--- a/oop/09-polymorphism/Customer.java
+++ /dev/null
@@ -1,60 +0,0 @@
-public class Customer {
- private int customerNumber;
- private String name;
- private String address;
- private String phone;
- private String mobile;
-
- public Customer() {
- }
-
- public Customer(int customerNumber, String name, String address,
- String phone, String mobile) {
- this.customerNumber = customerNumber;
- this.name = name;
- this.address = address;
- this.phone = phone;
- this.mobile = mobile;
- }
-
- public int getCustomerNumber() {
- return customerNumber;
- }
-
- public void setCustomerNumber(int customerNumber) {
- this.customerNumber = customerNumber;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getAddress() {
- return address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- }
-
- public String getPhone() {
- return phone;
- }
-
- public void setPhone(String phone) {
- this.phone = phone;
- }
-
- public String getMobile() {
- return mobile;
- }
-
- public void setMobile(String mobile) {
- this.mobile = mobile;
- }
-
-}
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();
- */
- }
-}
diff --git a/oop/09-polymorphism/CustomerDetailsFormatter.java b/oop/09-polymorphism/CustomerDetailsFormatter.java
deleted file mode 100644
index d2640e0..0000000
--- a/oop/09-polymorphism/CustomerDetailsFormatter.java
+++ /dev/null
@@ -1,17 +0,0 @@
-public class CustomerDetailsFormatter {
-
- /**
- * Format the customer object according to some needs
- * @param c
- * @return
- */
- public String getFormattedDescription(Customer c) {
- String buffer = "Customer description: \n";
- buffer += " Number: " + c.getCustomerNumber();
- buffer += " Name: " + c.getName();
- buffer += " Address: " + c.getAddress();
- buffer += "\n";
-
- return buffer;
- }
-}
diff --git a/oop/09-polymorphism/PremiumCustomer.java b/oop/09-polymorphism/PremiumCustomer.java
deleted file mode 100644
index a098af5..0000000
--- a/oop/09-polymorphism/PremiumCustomer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-public class PremiumCustomer extends Customer {
-
- private String category;
- private String desction;
-
-
- public PremiumCustomer() {
- }
-
- public PremiumCustomer(int customerNumber, String name, String address,
- String phone, String mobile) {
- super(customerNumber, name, address, phone, mobile);
- }
-
-
- public PremiumCustomer(int customerNumber, String name, String address,
- String phone, String mobile, String category, String desction) {
- super(customerNumber, name, address, phone, mobile);
- this.category = category;
- this.desction = desction;
- }
-
- public PremiumCustomer(String category, String desction) {
- super();
- this.category = category;
- this.desction = desction;
- }
-
- public String getCategory() {
- return category;
- }
- public void setCategory(String category) {
- this.category = category;
- }
- public String getDesction() {
- return desction;
- }
- public void setDesction(String desction) {
- this.desction = desction;
- }
-
-
-}