From baaba4a281b7d54e6b5d7767989c303b854b6932 Mon Sep 17 00:00:00 2001 From: Kamal Wickramanayake Date: Sun, 22 Feb 2026 19:43:58 +0530 Subject: Directory rename --- java-advanced/xx-nested-classes/.gitignore | 1 + java-advanced/xx-nested-classes/CreateInner.java | 16 ++++++ java-advanced/xx-nested-classes/MyOuter.java | 14 +++++ oop/01-account/.gitignore | 1 - oop/01-account/Account.java | 26 ---------- oop/01-account/AccountTest.java | 23 --------- oop/01-data-abstraction/.gitignore | 1 + oop/01-data-abstraction/Account.java | 26 ++++++++++ oop/01-data-abstraction/AccountTest.java | 23 +++++++++ oop/02-inheritance/.gitignore | 1 + oop/02-inheritance/Account.java | 24 +++++++++ oop/02-inheritance/AccountTest.java | 22 ++++++++ oop/02-inheritance/CheckingAccount.java | 20 ++++++++ oop/02-inheritance/SavingsAccount.java | 9 ++++ oop/02-non-static-methods/.gitignore | 1 - oop/02-non-static-methods/Calculator.java | 15 ------ oop/02-non-static-methods/MyApp.java | 13 ----- oop/03-interfaces/.gitignore | 1 + oop/03-interfaces/BasicCalculator.java | 15 ++++++ oop/03-interfaces/Calculator.java | 24 +++++++++ oop/03-interfaces/CalculatorTest.java | 9 ++++ oop/03-static-methods/.gitignore | 1 - oop/03-static-methods/Calculator.java | 29 ----------- oop/03-static-methods/MyApp.java | 25 --------- oop/04-constructors/.gitignore | 1 - oop/04-constructors/Account.java | 47 ----------------- oop/04-constructors/AccountTest.java | 23 --------- oop/04-encapsulation/.gitignore | 1 + oop/04-encapsulation/Account.java | 29 +++++++++++ oop/04-encapsulation/AccountTest.java | 16 ++++++ oop/05-destructor/.gitignore | 1 - oop/05-destructor/Account.java | 33 ------------ oop/05-destructor/AccountTest.java | 19 ------- oop/05-polymorphism/.gitignore | 1 + oop/05-polymorphism/Customer.java | 60 ++++++++++++++++++++++ oop/05-polymorphism/CustomerApp.java | 46 +++++++++++++++++ oop/05-polymorphism/CustomerDetailsFormatter.java | 17 ++++++ oop/05-polymorphism/PremiumCustomer.java | 43 ++++++++++++++++ oop/06-encapsulation/.gitignore | 1 - oop/06-encapsulation/Account.java | 29 ----------- oop/06-encapsulation/AccountTest.java | 16 ------ oop/06-static-properties/.gitignore | 1 + oop/06-static-properties/Calculator.java | 29 +++++++++++ oop/06-static-properties/MyApp.java | 25 +++++++++ oop/07-constructors/.gitignore | 1 + oop/07-constructors/Account.java | 47 +++++++++++++++++ oop/07-constructors/AccountTest.java | 23 +++++++++ oop/07-inheritance/.gitignore | 1 - oop/07-inheritance/Account.java | 24 --------- oop/07-inheritance/AccountTest.java | 22 -------- oop/07-inheritance/CheckingAccount.java | 20 -------- oop/07-inheritance/SavingsAccount.java | 9 ---- oop/08-destructor/.gitignore | 1 + oop/08-destructor/Account.java | 33 ++++++++++++ oop/08-destructor/AccountTest.java | 19 +++++++ oop/08-pass-by-value-reference/.gitignore | 1 - oop/08-pass-by-value-reference/Customer.java | 12 ----- .../PassByReference.java | 19 ------- oop/08-pass-by-value-reference/PassByValue.java | 17 ------ oop/09-pass-by-value-reference/.gitignore | 1 + oop/09-pass-by-value-reference/Customer.java | 12 +++++ .../PassByReference.java | 19 +++++++ oop/09-pass-by-value-reference/PassByValue.java | 17 ++++++ oop/09-polymorphism/.gitignore | 1 - oop/09-polymorphism/Customer.java | 60 ---------------------- oop/09-polymorphism/CustomerApp.java | 46 ----------------- oop/09-polymorphism/CustomerDetailsFormatter.java | 17 ------ oop/09-polymorphism/PremiumCustomer.java | 43 ---------------- oop/10-nested-classes/.gitignore | 1 - oop/10-nested-classes/CreateInner.java | 16 ------ oop/10-nested-classes/MyOuter.java | 14 ----- oop/11-interfaces/.gitignore | 1 - oop/11-interfaces/BasicCalculator.java | 15 ------ oop/11-interfaces/Calculator.java | 24 --------- oop/11-interfaces/CalculatorTest.java | 9 ---- 75 files changed, 647 insertions(+), 676 deletions(-) create mode 100644 java-advanced/xx-nested-classes/.gitignore create mode 100644 java-advanced/xx-nested-classes/CreateInner.java create mode 100644 java-advanced/xx-nested-classes/MyOuter.java delete mode 100644 oop/01-account/.gitignore delete mode 100644 oop/01-account/Account.java delete mode 100644 oop/01-account/AccountTest.java create mode 100644 oop/01-data-abstraction/.gitignore create mode 100644 oop/01-data-abstraction/Account.java create mode 100644 oop/01-data-abstraction/AccountTest.java create mode 100644 oop/02-inheritance/.gitignore create mode 100644 oop/02-inheritance/Account.java create mode 100644 oop/02-inheritance/AccountTest.java create mode 100644 oop/02-inheritance/CheckingAccount.java create mode 100644 oop/02-inheritance/SavingsAccount.java delete mode 100644 oop/02-non-static-methods/.gitignore delete mode 100644 oop/02-non-static-methods/Calculator.java delete mode 100644 oop/02-non-static-methods/MyApp.java create mode 100644 oop/03-interfaces/.gitignore create mode 100644 oop/03-interfaces/BasicCalculator.java create mode 100644 oop/03-interfaces/Calculator.java create mode 100644 oop/03-interfaces/CalculatorTest.java delete mode 100644 oop/03-static-methods/.gitignore delete mode 100644 oop/03-static-methods/Calculator.java delete mode 100644 oop/03-static-methods/MyApp.java delete mode 100644 oop/04-constructors/.gitignore delete mode 100644 oop/04-constructors/Account.java delete mode 100644 oop/04-constructors/AccountTest.java create mode 100644 oop/04-encapsulation/.gitignore create mode 100644 oop/04-encapsulation/Account.java create mode 100644 oop/04-encapsulation/AccountTest.java delete mode 100644 oop/05-destructor/.gitignore delete mode 100644 oop/05-destructor/Account.java delete mode 100644 oop/05-destructor/AccountTest.java create mode 100644 oop/05-polymorphism/.gitignore create mode 100644 oop/05-polymorphism/Customer.java create mode 100644 oop/05-polymorphism/CustomerApp.java create mode 100644 oop/05-polymorphism/CustomerDetailsFormatter.java create mode 100644 oop/05-polymorphism/PremiumCustomer.java delete mode 100644 oop/06-encapsulation/.gitignore delete mode 100644 oop/06-encapsulation/Account.java delete mode 100644 oop/06-encapsulation/AccountTest.java create mode 100644 oop/06-static-properties/.gitignore create mode 100644 oop/06-static-properties/Calculator.java create mode 100644 oop/06-static-properties/MyApp.java create mode 100644 oop/07-constructors/.gitignore create mode 100644 oop/07-constructors/Account.java create mode 100644 oop/07-constructors/AccountTest.java delete mode 100644 oop/07-inheritance/.gitignore delete mode 100644 oop/07-inheritance/Account.java delete mode 100644 oop/07-inheritance/AccountTest.java delete mode 100644 oop/07-inheritance/CheckingAccount.java delete mode 100644 oop/07-inheritance/SavingsAccount.java create mode 100644 oop/08-destructor/.gitignore create mode 100644 oop/08-destructor/Account.java create mode 100644 oop/08-destructor/AccountTest.java delete mode 100644 oop/08-pass-by-value-reference/.gitignore delete mode 100644 oop/08-pass-by-value-reference/Customer.java delete mode 100644 oop/08-pass-by-value-reference/PassByReference.java delete mode 100644 oop/08-pass-by-value-reference/PassByValue.java create mode 100644 oop/09-pass-by-value-reference/.gitignore create mode 100644 oop/09-pass-by-value-reference/Customer.java create mode 100644 oop/09-pass-by-value-reference/PassByReference.java create mode 100644 oop/09-pass-by-value-reference/PassByValue.java delete mode 100644 oop/09-polymorphism/.gitignore delete mode 100644 oop/09-polymorphism/Customer.java delete mode 100644 oop/09-polymorphism/CustomerApp.java delete mode 100644 oop/09-polymorphism/CustomerDetailsFormatter.java delete mode 100644 oop/09-polymorphism/PremiumCustomer.java delete mode 100644 oop/10-nested-classes/.gitignore delete mode 100644 oop/10-nested-classes/CreateInner.java delete mode 100644 oop/10-nested-classes/MyOuter.java delete mode 100644 oop/11-interfaces/.gitignore delete mode 100644 oop/11-interfaces/BasicCalculator.java delete mode 100644 oop/11-interfaces/Calculator.java delete mode 100644 oop/11-interfaces/CalculatorTest.java diff --git a/java-advanced/xx-nested-classes/.gitignore b/java-advanced/xx-nested-classes/.gitignore new file mode 100644 index 0000000..6b468b6 --- /dev/null +++ b/java-advanced/xx-nested-classes/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/java-advanced/xx-nested-classes/CreateInner.java b/java-advanced/xx-nested-classes/CreateInner.java new file mode 100644 index 0000000..ab3830e --- /dev/null +++ b/java-advanced/xx-nested-classes/CreateInner.java @@ -0,0 +1,16 @@ +public class CreateInner { + + public static void main(String[] args) { + MyOuter mo = new MyOuter(); + MyOuter.MyInner inner = mo.new MyInner(); + inner.seeOuter(); + } + + /* Here's another way (same thing!) + public static void main(String[] args) { + MyOuter.MyInner inner = new MyOuter().new MyInner(); + inner.seeOuter(); + } + */ + +} diff --git a/java-advanced/xx-nested-classes/MyOuter.java b/java-advanced/xx-nested-classes/MyOuter.java new file mode 100644 index 0000000..6821b98 --- /dev/null +++ b/java-advanced/xx-nested-classes/MyOuter.java @@ -0,0 +1,14 @@ +class MyOuter { + private int x = 7; + + public void makeInner() { + MyInner in = new MyInner(); + in.seeOuter(); + } + + class MyInner { + public void seeOuter() { + System.out.println("Outer x is " + x); + } + } +} \ No newline at end of file diff --git a/oop/01-account/.gitignore b/oop/01-account/.gitignore deleted file mode 100644 index 6b468b6..0000000 --- a/oop/01-account/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.class diff --git a/oop/01-account/Account.java b/oop/01-account/Account.java deleted file mode 100644 index 03a9e9c..0000000 --- a/oop/01-account/Account.java +++ /dev/null @@ -1,26 +0,0 @@ - -public class Account { - - /* Declaring fields - represent state */ - - int accountNumber; - double balance; - - - /* Declaring methods - represent operations */ - - public void withdraw(double amount) { - if (balance >= amount) { - balance = balance - amount; - } - } - - public void deposit(double amount) { - balance += amount; - } - - public double getBalance() { - return balance; - } - -} diff --git a/oop/01-account/AccountTest.java b/oop/01-account/AccountTest.java deleted file mode 100644 index 0409d86..0000000 --- a/oop/01-account/AccountTest.java +++ /dev/null @@ -1,23 +0,0 @@ - -public class AccountTest { - - /** - * @param args - */ - public static void main(String[] args) { - Account a1 = new Account(); // Instantiation of 'Account' class - Account a2 = new Account(); - - System.out.println(a1.getBalance()); - - a1.deposit(100.0); - System.out.println(a1.getBalance()); - - a1.withdraw(50.0); - System.out.println(a1.getBalance()); - - a2.deposit(100.0); - System.out.println(a2.getBalance()); - } - -} diff --git a/oop/01-data-abstraction/.gitignore b/oop/01-data-abstraction/.gitignore new file mode 100644 index 0000000..6b468b6 --- /dev/null +++ b/oop/01-data-abstraction/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/oop/01-data-abstraction/Account.java b/oop/01-data-abstraction/Account.java new file mode 100644 index 0000000..03a9e9c --- /dev/null +++ b/oop/01-data-abstraction/Account.java @@ -0,0 +1,26 @@ + +public class Account { + + /* Declaring fields - represent state */ + + int accountNumber; + double balance; + + + /* Declaring methods - represent operations */ + + public void withdraw(double amount) { + if (balance >= amount) { + balance = balance - amount; + } + } + + public void deposit(double amount) { + balance += amount; + } + + public double getBalance() { + return balance; + } + +} diff --git a/oop/01-data-abstraction/AccountTest.java b/oop/01-data-abstraction/AccountTest.java new file mode 100644 index 0000000..0409d86 --- /dev/null +++ b/oop/01-data-abstraction/AccountTest.java @@ -0,0 +1,23 @@ + +public class AccountTest { + + /** + * @param args + */ + public static void main(String[] args) { + Account a1 = new Account(); // Instantiation of 'Account' class + Account a2 = new Account(); + + System.out.println(a1.getBalance()); + + a1.deposit(100.0); + System.out.println(a1.getBalance()); + + a1.withdraw(50.0); + System.out.println(a1.getBalance()); + + a2.deposit(100.0); + System.out.println(a2.getBalance()); + } + +} diff --git a/oop/02-inheritance/.gitignore b/oop/02-inheritance/.gitignore new file mode 100644 index 0000000..6b468b6 --- /dev/null +++ b/oop/02-inheritance/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/oop/02-inheritance/Account.java b/oop/02-inheritance/Account.java new file mode 100644 index 0000000..91acb95 --- /dev/null +++ b/oop/02-inheritance/Account.java @@ -0,0 +1,24 @@ + +public abstract class Account { + + /* Declaring fields - represent state */ + protected int accountNumber; + protected double balance; + + public Account() { + /// + } + + /* Declaring methods - represent operations */ + + public abstract void withdraw(double amount); + + public void deposit(double amount) { + balance += amount; + } + + public double getBalance() { + return balance; + } + +} diff --git a/oop/02-inheritance/AccountTest.java b/oop/02-inheritance/AccountTest.java new file mode 100644 index 0000000..cc5056b --- /dev/null +++ b/oop/02-inheritance/AccountTest.java @@ -0,0 +1,22 @@ + +public class AccountTest { + + /** + * @param args + */ + public static void main(String[] args) { + SavingsAccount a1 = new SavingsAccount(); + + Account a3 = new SavingsAccount(); + + Account a2 = new CheckingAccount(); + + + + CheckingAccount a4 = new CheckingAccount(); + + +// CheckingAccount a5 = new SavingsAccount(); // not working + } + +} diff --git a/oop/02-inheritance/CheckingAccount.java b/oop/02-inheritance/CheckingAccount.java new file mode 100644 index 0000000..a7c19b8 --- /dev/null +++ b/oop/02-inheritance/CheckingAccount.java @@ -0,0 +1,20 @@ + +public class CheckingAccount extends Account { + + + protected double overdraftLimit; + + + public void withdraw(double amount) { + double finalBalance = balance - amount; + if (finalBalance < 0) { + if (-finalBalance <= overdraftLimit) { + balance = finalBalance; + } else { + // throw exception + } + } else { + balance = finalBalance; + } + } +} diff --git a/oop/02-inheritance/SavingsAccount.java b/oop/02-inheritance/SavingsAccount.java new file mode 100644 index 0000000..497fb3d --- /dev/null +++ b/oop/02-inheritance/SavingsAccount.java @@ -0,0 +1,9 @@ + +public class SavingsAccount extends Account { + + public void withdraw(double amount) { + if (balance >= amount) { + balance = balance - amount; + } + } +} diff --git a/oop/02-non-static-methods/.gitignore b/oop/02-non-static-methods/.gitignore deleted file mode 100644 index 6b468b6..0000000 --- a/oop/02-non-static-methods/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.class diff --git a/oop/02-non-static-methods/Calculator.java b/oop/02-non-static-methods/Calculator.java deleted file mode 100644 index ecc7234..0000000 --- a/oop/02-non-static-methods/Calculator.java +++ /dev/null @@ -1,15 +0,0 @@ - -public class Calculator { - - public int add(int a, int b) { - return a + b; - } - - public int subtract(int a, int b) { - return a - b; - } - - public double convertFromC2F(double cTemp) { - return cTemp*180/100 + 32.0; - } -} diff --git a/oop/02-non-static-methods/MyApp.java b/oop/02-non-static-methods/MyApp.java deleted file mode 100644 index 2ebdcae..0000000 --- a/oop/02-non-static-methods/MyApp.java +++ /dev/null @@ -1,13 +0,0 @@ - -public class MyApp { - - /** - * @param args - */ - public static void main(String[] args) { - Calculator cal = new Calculator(); - - System.out.println(cal.convertFromC2F(100.0)); - } - -} diff --git a/oop/03-interfaces/.gitignore b/oop/03-interfaces/.gitignore new file mode 100644 index 0000000..6b468b6 --- /dev/null +++ b/oop/03-interfaces/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/oop/03-interfaces/BasicCalculator.java b/oop/03-interfaces/BasicCalculator.java new file mode 100644 index 0000000..f087d81 --- /dev/null +++ b/oop/03-interfaces/BasicCalculator.java @@ -0,0 +1,15 @@ +//public class BasicCalculator implements Calculator, ScientificCalculator { +public class BasicCalculator implements Calculator { + + public int add(int a, int b) { + return a + b; + } + + public int subtract(int a, int b) { + return a - b; + } + + public double divide(double a, double b) { + return a / b; + } +} diff --git a/oop/03-interfaces/Calculator.java b/oop/03-interfaces/Calculator.java new file mode 100644 index 0000000..aa716b0 --- /dev/null +++ b/oop/03-interfaces/Calculator.java @@ -0,0 +1,24 @@ +//abstract interface Calculator { +interface Calculator { + public final static double PI = 3.14; + + // double PI = 3.14; + // public static double PI = 3.14; + // public final double PI = 3.14; + // final double PI = 3.14; + // static double PI = 3.14; + + public int add(int a, int b); + // int add(int a, int b); + // abstract int add(int a, int b); + // public abstract int add(int a, int b); + + // static int add(int a, int b); // Not allowed + // int add(int a, int b); // Allowed + +// public int subtract(int a, int b); +// int subtract(int a, int b); + abstract int subtract(int a, int b); + + public double divide(double a, double b); +} diff --git a/oop/03-interfaces/CalculatorTest.java b/oop/03-interfaces/CalculatorTest.java new file mode 100644 index 0000000..e2340dd --- /dev/null +++ b/oop/03-interfaces/CalculatorTest.java @@ -0,0 +1,9 @@ +public class CalculatorTest { + + public static void main(String[] args) { + Calculator cal = new BasicCalculator(); + + System.out.println(cal.add(1, 3)); + //.... + } +} diff --git a/oop/03-static-methods/.gitignore b/oop/03-static-methods/.gitignore deleted file mode 100644 index 6b468b6..0000000 --- a/oop/03-static-methods/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.class diff --git a/oop/03-static-methods/Calculator.java b/oop/03-static-methods/Calculator.java deleted file mode 100644 index 7ec2851..0000000 --- a/oop/03-static-methods/Calculator.java +++ /dev/null @@ -1,29 +0,0 @@ - -public class Calculator { - public static int x; // static (class) field - public int y; // instance field - - public static int add(int a, int b) { // static (class) method - return a + b; - } - - public static int subtract(int a, int b) { // static (class) method - return a - b; - } - - public static double convertFromC2F(double cTemp) { // static (class) method - return cTemp*180/100 + 32.0; - } - - public void setY(int y) { // instance method - this.y = y; - } - - public int getXxY() { // instance method - return x * y; - } - -// public static int getXxY2() { -// return x * y; -// } -} diff --git a/oop/03-static-methods/MyApp.java b/oop/03-static-methods/MyApp.java deleted file mode 100644 index 0137433..0000000 --- a/oop/03-static-methods/MyApp.java +++ /dev/null @@ -1,25 +0,0 @@ - -public class MyApp { - - /** - * @param args - */ - public static void main(String[] args) { - System.out.println(Calculator.convertFromC2F(100.0)); - - Calculator.x = 5; - - Calculator cal1 = new Calculator(); - cal1.setY(10); - System.out.println(cal1.getXxY()); // prints 50 - - Calculator cal2 = new Calculator(); - cal2.setY(11); - - Calculator.x = 6; - - System.out.println(cal1.getXxY()); // 60 - System.out.println(cal2.getXxY()); // 66 - } - -} diff --git a/oop/04-constructors/.gitignore b/oop/04-constructors/.gitignore deleted file mode 100644 index 6b468b6..0000000 --- a/oop/04-constructors/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.class diff --git a/oop/04-constructors/Account.java b/oop/04-constructors/Account.java deleted file mode 100644 index 82875be..0000000 --- a/oop/04-constructors/Account.java +++ /dev/null @@ -1,47 +0,0 @@ - -public class Account { - - /* Declaring fields - represent state */ - - int accountNumber; - double balance; - - // No argument constructor - public Account() { - System.out.println("No argument constructor"); - } - - // A constructor with an argument - public Account(double initialBalance) { - balance = initialBalance; - System.out.println("Argument constructor"); - } - - /* Declaring methods - represent operations */ - - public void withdraw(double amount) { - if (balance >= amount) { - balance = balance - amount; - } - } - - // Overloaded method - public void deposit(double amount) { - balance += amount; - } - - // Overloaded method - public void deposit(int amount) { - balance += amount; - } - - - public double getBalance() { - return balance; - } - - -// public int getBalance() { -// return 1; -// } -} diff --git a/oop/04-constructors/AccountTest.java b/oop/04-constructors/AccountTest.java deleted file mode 100644 index 9774e84..0000000 --- a/oop/04-constructors/AccountTest.java +++ /dev/null @@ -1,23 +0,0 @@ - -public class AccountTest { - - /** - * @param args - */ - public static void main(String[] args) { - Account a1 = new Account(); // Instantiation of 'Account' class - Account a2 = new Account(10.0); - - System.out.println(a1.getBalance()); - - a1.deposit(100.0); - System.out.println(a1.getBalance()); - - a1.withdraw(50.0); - System.out.println(a1.getBalance()); - - a2.deposit(100.0); - System.out.println(a2.getBalance()); - } - -} diff --git a/oop/04-encapsulation/.gitignore b/oop/04-encapsulation/.gitignore new file mode 100644 index 0000000..6b468b6 --- /dev/null +++ b/oop/04-encapsulation/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/oop/04-encapsulation/Account.java b/oop/04-encapsulation/Account.java new file mode 100644 index 0000000..55d99d0 --- /dev/null +++ b/oop/04-encapsulation/Account.java @@ -0,0 +1,29 @@ + +public class Account { + + /* Declaring fields - represent state */ + + private int accountNumber; + private double balance; + + + /* Declaring methods - represent operations */ + + public void withdraw(double amount) { + if (balance >= amount) { + balance = balance - amount; + } + } + + public void deposit(double amount) { + balance += amount; + } + + public double getBalance() { + return balance; + } + + public void setBalance(double newBalance) { + balance = newBalance; + } +} diff --git a/oop/04-encapsulation/AccountTest.java b/oop/04-encapsulation/AccountTest.java new file mode 100644 index 0000000..9242cea --- /dev/null +++ b/oop/04-encapsulation/AccountTest.java @@ -0,0 +1,16 @@ + +public class AccountTest { + + /** + * @param args + */ + public static void main(String[] args) { + Account a1 = new Account(); // Instantiation of 'Account' class + + a1.setBalance(200.0); + +// a1.deposit(100.0); +// a1.withdraw(10.0); + } + +} diff --git a/oop/05-destructor/.gitignore b/oop/05-destructor/.gitignore deleted file mode 100644 index 6b468b6..0000000 --- a/oop/05-destructor/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.class diff --git a/oop/05-destructor/Account.java b/oop/05-destructor/Account.java deleted file mode 100644 index a5baab7..0000000 --- a/oop/05-destructor/Account.java +++ /dev/null @@ -1,33 +0,0 @@ - -public class Account { - - /* Declaring fields - represent state */ - - int accountNumber; - double balance; - - /* Declaring methods - represent operations */ - - /* - * Here is a useless destructor just for testing. - */ - public void finalize() { - System.out.println("Object is being descarded"); - System.exit(0); - } - - public void withdraw(double amount) { - if (balance >= amount) { - balance = balance - amount; - } - } - - public void deposit(double amount) { - balance += amount; - } - - public double getBalance() { - return balance; - } - -} diff --git a/oop/05-destructor/AccountTest.java b/oop/05-destructor/AccountTest.java deleted file mode 100644 index 8c9f474..0000000 --- a/oop/05-destructor/AccountTest.java +++ /dev/null @@ -1,19 +0,0 @@ - -public class AccountTest { - - /** - * @param args - */ - public static void main(String[] args) { - Account a1 = new Account(); - //.... - //.... - a1 = new Account(); - - while (true) { - new Account(); - } - - } - -} diff --git a/oop/05-polymorphism/.gitignore b/oop/05-polymorphism/.gitignore new file mode 100644 index 0000000..6b468b6 --- /dev/null +++ b/oop/05-polymorphism/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/oop/05-polymorphism/Customer.java b/oop/05-polymorphism/Customer.java new file mode 100644 index 0000000..56b0f7b --- /dev/null +++ b/oop/05-polymorphism/Customer.java @@ -0,0 +1,60 @@ +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/05-polymorphism/CustomerApp.java b/oop/05-polymorphism/CustomerApp.java new file mode 100644 index 0000000..79e1c31 --- /dev/null +++ b/oop/05-polymorphism/CustomerApp.java @@ -0,0 +1,46 @@ +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/05-polymorphism/CustomerDetailsFormatter.java b/oop/05-polymorphism/CustomerDetailsFormatter.java new file mode 100644 index 0000000..d2640e0 --- /dev/null +++ b/oop/05-polymorphism/CustomerDetailsFormatter.java @@ -0,0 +1,17 @@ +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/05-polymorphism/PremiumCustomer.java b/oop/05-polymorphism/PremiumCustomer.java new file mode 100644 index 0000000..a098af5 --- /dev/null +++ b/oop/05-polymorphism/PremiumCustomer.java @@ -0,0 +1,43 @@ +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; + } + + +} diff --git a/oop/06-encapsulation/.gitignore b/oop/06-encapsulation/.gitignore deleted file mode 100644 index 6b468b6..0000000 --- a/oop/06-encapsulation/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.class diff --git a/oop/06-encapsulation/Account.java b/oop/06-encapsulation/Account.java deleted file mode 100644 index 55d99d0..0000000 --- a/oop/06-encapsulation/Account.java +++ /dev/null @@ -1,29 +0,0 @@ - -public class Account { - - /* Declaring fields - represent state */ - - private int accountNumber; - private double balance; - - - /* Declaring methods - represent operations */ - - public void withdraw(double amount) { - if (balance >= amount) { - balance = balance - amount; - } - } - - public void deposit(double amount) { - balance += amount; - } - - public double getBalance() { - return balance; - } - - public void setBalance(double newBalance) { - balance = newBalance; - } -} diff --git a/oop/06-encapsulation/AccountTest.java b/oop/06-encapsulation/AccountTest.java deleted file mode 100644 index 9242cea..0000000 --- a/oop/06-encapsulation/AccountTest.java +++ /dev/null @@ -1,16 +0,0 @@ - -public class AccountTest { - - /** - * @param args - */ - public static void main(String[] args) { - Account a1 = new Account(); // Instantiation of 'Account' class - - a1.setBalance(200.0); - -// a1.deposit(100.0); -// a1.withdraw(10.0); - } - -} diff --git a/oop/06-static-properties/.gitignore b/oop/06-static-properties/.gitignore new file mode 100644 index 0000000..6b468b6 --- /dev/null +++ b/oop/06-static-properties/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/oop/06-static-properties/Calculator.java b/oop/06-static-properties/Calculator.java new file mode 100644 index 0000000..7ec2851 --- /dev/null +++ b/oop/06-static-properties/Calculator.java @@ -0,0 +1,29 @@ + +public class Calculator { + public static int x; // static (class) field + public int y; // instance field + + public static int add(int a, int b) { // static (class) method + return a + b; + } + + public static int subtract(int a, int b) { // static (class) method + return a - b; + } + + public static double convertFromC2F(double cTemp) { // static (class) method + return cTemp*180/100 + 32.0; + } + + public void setY(int y) { // instance method + this.y = y; + } + + public int getXxY() { // instance method + return x * y; + } + +// public static int getXxY2() { +// return x * y; +// } +} diff --git a/oop/06-static-properties/MyApp.java b/oop/06-static-properties/MyApp.java new file mode 100644 index 0000000..0137433 --- /dev/null +++ b/oop/06-static-properties/MyApp.java @@ -0,0 +1,25 @@ + +public class MyApp { + + /** + * @param args + */ + public static void main(String[] args) { + System.out.println(Calculator.convertFromC2F(100.0)); + + Calculator.x = 5; + + Calculator cal1 = new Calculator(); + cal1.setY(10); + System.out.println(cal1.getXxY()); // prints 50 + + Calculator cal2 = new Calculator(); + cal2.setY(11); + + Calculator.x = 6; + + System.out.println(cal1.getXxY()); // 60 + System.out.println(cal2.getXxY()); // 66 + } + +} diff --git a/oop/07-constructors/.gitignore b/oop/07-constructors/.gitignore new file mode 100644 index 0000000..6b468b6 --- /dev/null +++ b/oop/07-constructors/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/oop/07-constructors/Account.java b/oop/07-constructors/Account.java new file mode 100644 index 0000000..82875be --- /dev/null +++ b/oop/07-constructors/Account.java @@ -0,0 +1,47 @@ + +public class Account { + + /* Declaring fields - represent state */ + + int accountNumber; + double balance; + + // No argument constructor + public Account() { + System.out.println("No argument constructor"); + } + + // A constructor with an argument + public Account(double initialBalance) { + balance = initialBalance; + System.out.println("Argument constructor"); + } + + /* Declaring methods - represent operations */ + + public void withdraw(double amount) { + if (balance >= amount) { + balance = balance - amount; + } + } + + // Overloaded method + public void deposit(double amount) { + balance += amount; + } + + // Overloaded method + public void deposit(int amount) { + balance += amount; + } + + + public double getBalance() { + return balance; + } + + +// public int getBalance() { +// return 1; +// } +} diff --git a/oop/07-constructors/AccountTest.java b/oop/07-constructors/AccountTest.java new file mode 100644 index 0000000..9774e84 --- /dev/null +++ b/oop/07-constructors/AccountTest.java @@ -0,0 +1,23 @@ + +public class AccountTest { + + /** + * @param args + */ + public static void main(String[] args) { + Account a1 = new Account(); // Instantiation of 'Account' class + Account a2 = new Account(10.0); + + System.out.println(a1.getBalance()); + + a1.deposit(100.0); + System.out.println(a1.getBalance()); + + a1.withdraw(50.0); + System.out.println(a1.getBalance()); + + a2.deposit(100.0); + System.out.println(a2.getBalance()); + } + +} diff --git a/oop/07-inheritance/.gitignore b/oop/07-inheritance/.gitignore deleted file mode 100644 index 6b468b6..0000000 --- a/oop/07-inheritance/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.class diff --git a/oop/07-inheritance/Account.java b/oop/07-inheritance/Account.java deleted file mode 100644 index 91acb95..0000000 --- a/oop/07-inheritance/Account.java +++ /dev/null @@ -1,24 +0,0 @@ - -public abstract class Account { - - /* Declaring fields - represent state */ - protected int accountNumber; - protected double balance; - - public Account() { - /// - } - - /* Declaring methods - represent operations */ - - public abstract void withdraw(double amount); - - public void deposit(double amount) { - balance += amount; - } - - public double getBalance() { - return balance; - } - -} diff --git a/oop/07-inheritance/AccountTest.java b/oop/07-inheritance/AccountTest.java deleted file mode 100644 index cc5056b..0000000 --- a/oop/07-inheritance/AccountTest.java +++ /dev/null @@ -1,22 +0,0 @@ - -public class AccountTest { - - /** - * @param args - */ - public static void main(String[] args) { - SavingsAccount a1 = new SavingsAccount(); - - Account a3 = new SavingsAccount(); - - Account a2 = new CheckingAccount(); - - - - CheckingAccount a4 = new CheckingAccount(); - - -// CheckingAccount a5 = new SavingsAccount(); // not working - } - -} diff --git a/oop/07-inheritance/CheckingAccount.java b/oop/07-inheritance/CheckingAccount.java deleted file mode 100644 index a7c19b8..0000000 --- a/oop/07-inheritance/CheckingAccount.java +++ /dev/null @@ -1,20 +0,0 @@ - -public class CheckingAccount extends Account { - - - protected double overdraftLimit; - - - public void withdraw(double amount) { - double finalBalance = balance - amount; - if (finalBalance < 0) { - if (-finalBalance <= overdraftLimit) { - balance = finalBalance; - } else { - // throw exception - } - } else { - balance = finalBalance; - } - } -} diff --git a/oop/07-inheritance/SavingsAccount.java b/oop/07-inheritance/SavingsAccount.java deleted file mode 100644 index 497fb3d..0000000 --- a/oop/07-inheritance/SavingsAccount.java +++ /dev/null @@ -1,9 +0,0 @@ - -public class SavingsAccount extends Account { - - public void withdraw(double amount) { - if (balance >= amount) { - balance = balance - amount; - } - } -} diff --git a/oop/08-destructor/.gitignore b/oop/08-destructor/.gitignore new file mode 100644 index 0000000..6b468b6 --- /dev/null +++ b/oop/08-destructor/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/oop/08-destructor/Account.java b/oop/08-destructor/Account.java new file mode 100644 index 0000000..a5baab7 --- /dev/null +++ b/oop/08-destructor/Account.java @@ -0,0 +1,33 @@ + +public class Account { + + /* Declaring fields - represent state */ + + int accountNumber; + double balance; + + /* Declaring methods - represent operations */ + + /* + * Here is a useless destructor just for testing. + */ + public void finalize() { + System.out.println("Object is being descarded"); + System.exit(0); + } + + public void withdraw(double amount) { + if (balance >= amount) { + balance = balance - amount; + } + } + + public void deposit(double amount) { + balance += amount; + } + + public double getBalance() { + return balance; + } + +} diff --git a/oop/08-destructor/AccountTest.java b/oop/08-destructor/AccountTest.java new file mode 100644 index 0000000..8c9f474 --- /dev/null +++ b/oop/08-destructor/AccountTest.java @@ -0,0 +1,19 @@ + +public class AccountTest { + + /** + * @param args + */ + public static void main(String[] args) { + Account a1 = new Account(); + //.... + //.... + a1 = new Account(); + + while (true) { + new Account(); + } + + } + +} diff --git a/oop/08-pass-by-value-reference/.gitignore b/oop/08-pass-by-value-reference/.gitignore deleted file mode 100644 index 6b468b6..0000000 --- a/oop/08-pass-by-value-reference/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.class diff --git a/oop/08-pass-by-value-reference/Customer.java b/oop/08-pass-by-value-reference/Customer.java deleted file mode 100644 index d092a3d..0000000 --- a/oop/08-pass-by-value-reference/Customer.java +++ /dev/null @@ -1,12 +0,0 @@ -public class Customer { - private int number; - - public int getNumber() { - return number; - } - - public void setNumber(int number) { - this.number = number; - } - -} diff --git a/oop/08-pass-by-value-reference/PassByReference.java b/oop/08-pass-by-value-reference/PassByReference.java deleted file mode 100644 index 8eb577a..0000000 --- a/oop/08-pass-by-value-reference/PassByReference.java +++ /dev/null @@ -1,19 +0,0 @@ -public class PassByReference { - - /** - * @param args - */ - public static void main(String[] args) { - Customer c = new Customer(); - c.setNumber(5); - System.out.println(c.getNumber()); // 5 - methodX(c); - System.out.println(c.getNumber()); // ? - } - - public static void methodX(Customer c2) { - System.out.println(c2.getNumber()); // 5 - c2.setNumber(6); - System.out.println(c2.getNumber()); // 6 - } -} diff --git a/oop/08-pass-by-value-reference/PassByValue.java b/oop/08-pass-by-value-reference/PassByValue.java deleted file mode 100644 index 2500d03..0000000 --- a/oop/08-pass-by-value-reference/PassByValue.java +++ /dev/null @@ -1,17 +0,0 @@ -public class PassByValue { - - /** - * @param args - */ - public static void main(String[] args) { - int x = 4; - System.out.println(x); // 4 - method(x, 2); - System.out.println(x); // ? - } - - public static void method(int x, int b) { - x = x + 1; - System.out.println(x); // 5 - } -} diff --git a/oop/09-pass-by-value-reference/.gitignore b/oop/09-pass-by-value-reference/.gitignore new file mode 100644 index 0000000..6b468b6 --- /dev/null +++ b/oop/09-pass-by-value-reference/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/oop/09-pass-by-value-reference/Customer.java b/oop/09-pass-by-value-reference/Customer.java new file mode 100644 index 0000000..d092a3d --- /dev/null +++ b/oop/09-pass-by-value-reference/Customer.java @@ -0,0 +1,12 @@ +public class Customer { + private int number; + + public int getNumber() { + return number; + } + + public void setNumber(int number) { + this.number = number; + } + +} diff --git a/oop/09-pass-by-value-reference/PassByReference.java b/oop/09-pass-by-value-reference/PassByReference.java new file mode 100644 index 0000000..8eb577a --- /dev/null +++ b/oop/09-pass-by-value-reference/PassByReference.java @@ -0,0 +1,19 @@ +public class PassByReference { + + /** + * @param args + */ + public static void main(String[] args) { + Customer c = new Customer(); + c.setNumber(5); + System.out.println(c.getNumber()); // 5 + methodX(c); + System.out.println(c.getNumber()); // ? + } + + public static void methodX(Customer c2) { + System.out.println(c2.getNumber()); // 5 + c2.setNumber(6); + System.out.println(c2.getNumber()); // 6 + } +} diff --git a/oop/09-pass-by-value-reference/PassByValue.java b/oop/09-pass-by-value-reference/PassByValue.java new file mode 100644 index 0000000..2500d03 --- /dev/null +++ b/oop/09-pass-by-value-reference/PassByValue.java @@ -0,0 +1,17 @@ +public class PassByValue { + + /** + * @param args + */ + public static void main(String[] args) { + int x = 4; + System.out.println(x); // 4 + method(x, 2); + System.out.println(x); // ? + } + + public static void method(int x, int b) { + x = x + 1; + System.out.println(x); // 5 + } +} 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; - } - - -} diff --git a/oop/10-nested-classes/.gitignore b/oop/10-nested-classes/.gitignore deleted file mode 100644 index 6b468b6..0000000 --- a/oop/10-nested-classes/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.class diff --git a/oop/10-nested-classes/CreateInner.java b/oop/10-nested-classes/CreateInner.java deleted file mode 100644 index ab3830e..0000000 --- a/oop/10-nested-classes/CreateInner.java +++ /dev/null @@ -1,16 +0,0 @@ -public class CreateInner { - - public static void main(String[] args) { - MyOuter mo = new MyOuter(); - MyOuter.MyInner inner = mo.new MyInner(); - inner.seeOuter(); - } - - /* Here's another way (same thing!) - public static void main(String[] args) { - MyOuter.MyInner inner = new MyOuter().new MyInner(); - inner.seeOuter(); - } - */ - -} diff --git a/oop/10-nested-classes/MyOuter.java b/oop/10-nested-classes/MyOuter.java deleted file mode 100644 index 6821b98..0000000 --- a/oop/10-nested-classes/MyOuter.java +++ /dev/null @@ -1,14 +0,0 @@ -class MyOuter { - private int x = 7; - - public void makeInner() { - MyInner in = new MyInner(); - in.seeOuter(); - } - - class MyInner { - public void seeOuter() { - System.out.println("Outer x is " + x); - } - } -} \ No newline at end of file diff --git a/oop/11-interfaces/.gitignore b/oop/11-interfaces/.gitignore deleted file mode 100644 index 6b468b6..0000000 --- a/oop/11-interfaces/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.class diff --git a/oop/11-interfaces/BasicCalculator.java b/oop/11-interfaces/BasicCalculator.java deleted file mode 100644 index f087d81..0000000 --- a/oop/11-interfaces/BasicCalculator.java +++ /dev/null @@ -1,15 +0,0 @@ -//public class BasicCalculator implements Calculator, ScientificCalculator { -public class BasicCalculator implements Calculator { - - public int add(int a, int b) { - return a + b; - } - - public int subtract(int a, int b) { - return a - b; - } - - public double divide(double a, double b) { - return a / b; - } -} diff --git a/oop/11-interfaces/Calculator.java b/oop/11-interfaces/Calculator.java deleted file mode 100644 index aa716b0..0000000 --- a/oop/11-interfaces/Calculator.java +++ /dev/null @@ -1,24 +0,0 @@ -//abstract interface Calculator { -interface Calculator { - public final static double PI = 3.14; - - // double PI = 3.14; - // public static double PI = 3.14; - // public final double PI = 3.14; - // final double PI = 3.14; - // static double PI = 3.14; - - public int add(int a, int b); - // int add(int a, int b); - // abstract int add(int a, int b); - // public abstract int add(int a, int b); - - // static int add(int a, int b); // Not allowed - // int add(int a, int b); // Allowed - -// public int subtract(int a, int b); -// int subtract(int a, int b); - abstract int subtract(int a, int b); - - public double divide(double a, double b); -} diff --git a/oop/11-interfaces/CalculatorTest.java b/oop/11-interfaces/CalculatorTest.java deleted file mode 100644 index e2340dd..0000000 --- a/oop/11-interfaces/CalculatorTest.java +++ /dev/null @@ -1,9 +0,0 @@ -public class CalculatorTest { - - public static void main(String[] args) { - Calculator cal = new BasicCalculator(); - - System.out.println(cal.add(1, 3)); - //.... - } -} -- cgit v1.2.3