Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions OOPExamples/Calculator.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
33 changes: 33 additions & 0 deletions OOPExamples/Employee.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

Loading