Skip to content

Commit 45fc339

Browse files
committed
step 1: added calculator class
1 parent b643cbe commit 45fc339

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

src/com/premaseem/Calculator.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.premaseem;
2+
3+
/*
4+
@author: Aseem Jain
5+
@title: Design Patterns with Java 9
6+
@link: https://premaseem.wordpress.com/category/computers/design-patterns/
7+
*/
8+
public class Calculator {
9+
10+
public Integer add(Integer sum, Integer number){
11+
return sum + number;
12+
}
13+
}

src/com/premaseem/Client.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.premaseem;
2+
3+
/*
4+
@author: Aseem Jain
5+
@title: Design Patterns with Java 9
6+
@link: https://premaseem.wordpress.com/category/computers/design-patterns/
7+
@copyright: 2018 Packt Publication
8+
*/
9+
public class Client {
10+
public static void main (String[] args) {
11+
System.out.println("program to add number");
12+
Integer sum = calculateSum();
13+
System.out.println("total of all numbers is "+ sum);
14+
}
15+
16+
private static Integer calculateSum () {
17+
Integer sum = 0;
18+
for (int i =0; i< 1000; i++){
19+
Calculator calc = new Calculator();
20+
sum = calc.add(sum,i);
21+
}
22+
return sum;
23+
}
24+
}

0 commit comments

Comments
 (0)