Skip to content

Commit 3916588

Browse files
committed
Added Calculator class with basic operations
1 parent e64efdc commit 3916588

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

OOPExamples/Calculator.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class Calculator {
2+
public int add(int a, int b) {
3+
return a + b;
4+
}
5+
public int subtract(int a, int b) {
6+
return a - b;
7+
}
8+
public int multiply(int a, int b) {
9+
return a * b;
10+
}
11+
public int divide(int a, int b) {
12+
return b != 0 ? a / b : 0;
13+
}
14+
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
public class Student {
1+
public class Employee {
22
private String name;
33
private int age;
4-
private int roll;
4+
private int id;
55

66
//constructors
7-
public Student(String name, int age, int rollNo){
7+
public Employee(String name, int age, int id){
88
this.name = name;
99
this.age = age;
10-
this.rollNo = roll;
10+
this.id = id;
1111
}
1212
//getters
1313
public String getName(){
@@ -16,8 +16,8 @@ public String getName(){
1616
public int getAge(){
1717
return age;
1818
}
19-
public int getRollNo() {
20-
return roll;
19+
public int getIDNo() {
20+
return id;
2121
}
2222
//setters
2323
public void setName(String name) {
@@ -26,8 +26,8 @@ public void setName(String name) {
2626
public void setAge(int age) {
2727
this.age = age;
2828
}
29-
public void setRollNo(int rollNo) {
30-
this.rollNo = roll;
29+
public void setIDNo(int id) {
30+
this.id = id;
3131
}
3232
}
3333

0 commit comments

Comments
 (0)