-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathWithOutReflection.java
More file actions
79 lines (72 loc) · 1.64 KB
/
WithOutReflection.java
File metadata and controls
79 lines (72 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import java.util.Scanner;
class BigValueCalculator
{
BigValueCalculator(){
System.out.println("BigValueCalculator Cons Call");
}
public long add(long x,long y){
return x + y;
}
public long subtract(long x, long y){
return x - y;
}
public long multiply(long x,long y){
return x * y;
}
public long divide(long x,long y){
return x / y;
}
}
class Calculator
{
Calculator(){
System.out.println("Calculator Cons call");
}
private int add(int x,int y){
return x + y;
}
public int subtract(int x,int y){
return x - y;
}
public int multiply(int x,int y){
return x * y;
}
public int divide(int x,int y){
return x / y;
}
}
public class WithOutReflection {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
System.out.println("Type Calculator for int Calc");
System.out.println("Type BigValueCalculator for long Calc");
String calcChoice = scanner.next();
if(calcChoice.equals("Calculator")){
Calculator calc = new Calculator();
System.out.println("Type Add for Addition");
System.out.println("Type Subtract for Subtraction");
System.out.println("Type Multiply for Multiplication");
System.out.println("Type Divide for Division");
String choice = scanner.next().toLowerCase();
switch(choice){
case "add":
//System.out.println(calc.add(100, 200));
break;
case "subtract":
System.out.println(calc.subtract(100, 200));
break;
case "multiply":
System.out.println(calc.multiply(100, 200));
break;
case "divide":
System.out.println(calc.divide(100, 200));
break;
}
}
else
{
// BigValue Calculator
}
}
}