diff --git a/OOPExamples/Calculator.java b/OOPExamples/Calculator.java new file mode 100644 index 000000000000..e9f02acde388 --- /dev/null +++ b/OOPExamples/Calculator.java @@ -0,0 +1,14 @@ +public class Calculator { + public int add(int a, int b) { + return a + b; + } + public int subtract(int a, int b) { + return a - b; + } + public int multiply(int a, int b) { + return a * b; + } + public int divide(int a, int b) { + return b != 0 ? a / b : 0; + } +} diff --git a/OOPExamples/Employee.java b/OOPExamples/Employee.java new file mode 100644 index 000000000000..4d0780f32477 --- /dev/null +++ b/OOPExamples/Employee.java @@ -0,0 +1,33 @@ +public class Employee { + private String name; + private int age; + private int id; + + //constructors + public Employee(String name, int age, int id){ + this.name = name; + this.age = age; + this.id = id; + } + //getters + public String getName(){ + return name; + } + public int getAge(){ + return age; + } + public int getIDNo() { + return id; + } + //setters + public void setName(String name) { + this.name = name; + } + public void setAge(int age) { + this.age = age; + } + public void setIDNo(int id) { + this.id = id; + } +} +