diff options
| author | Kamal Wickramanayake <kamal@inbox.lk> | 2026-02-21 19:56:23 +0530 |
|---|---|---|
| committer | Kamal Wickramanayake <kamal@inbox.lk> | 2026-02-21 19:56:23 +0530 |
| commit | fab39307b045215fb465701009bb0d454788a4ca (patch) | |
| tree | be32da2848f862827b5c3552a3b60c32389fa35e /oop/02-non-static-methods | |
| parent | f0a5509cc57cbd6fc95728fb8566ce011d34cebd (diff) | |
Added simple OOP sample code.
Diffstat (limited to 'oop/02-non-static-methods')
| -rw-r--r-- | oop/02-non-static-methods/.gitignore | 1 | ||||
| -rw-r--r-- | oop/02-non-static-methods/Calculator.java | 15 | ||||
| -rw-r--r-- | oop/02-non-static-methods/MyApp.java | 13 |
3 files changed, 29 insertions, 0 deletions
diff --git a/oop/02-non-static-methods/.gitignore b/oop/02-non-static-methods/.gitignore new file mode 100644 index 0000000..6b468b6 --- /dev/null +++ b/oop/02-non-static-methods/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/oop/02-non-static-methods/Calculator.java b/oop/02-non-static-methods/Calculator.java new file mode 100644 index 0000000..ecc7234 --- /dev/null +++ b/oop/02-non-static-methods/Calculator.java @@ -0,0 +1,15 @@ + +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 new file mode 100644 index 0000000..2ebdcae --- /dev/null +++ b/oop/02-non-static-methods/MyApp.java @@ -0,0 +1,13 @@ + +public class MyApp { + + /** + * @param args + */ + public static void main(String[] args) { + Calculator cal = new Calculator(); + + System.out.println(cal.convertFromC2F(100.0)); + } + +} |
