summaryrefslogtreecommitdiff
path: root/oop/07-inheritance
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/07-inheritance
parentae4cf7c9f0a0b90d02166b43402e67b7d4ad4dca (diff)
Directory rename
Diffstat (limited to 'oop/07-inheritance')
-rw-r--r--oop/07-inheritance/.gitignore1
-rw-r--r--oop/07-inheritance/Account.java24
-rw-r--r--oop/07-inheritance/AccountTest.java22
-rw-r--r--oop/07-inheritance/CheckingAccount.java20
-rw-r--r--oop/07-inheritance/SavingsAccount.java9
5 files changed, 0 insertions, 76 deletions
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;
- }
- }
-}