Created
November 21, 2019 08:58
-
-
Save lucamolteni/725f5bac7778ec70693681bf8905cb7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Scratch { | |
public static void main(String[] args) { | |
SumOOP sumOOP = new SumOOP(2, 3); | |
System.out.println("sumOOP = " + sumOOP.compute()); | |
SumNoOOP sumNoOOP = new SumNoOOP(2, 3); | |
int sumNoOOp = sumNoOOP.getA() + sumNoOOP.getB(); | |
System.out.println("sumNoOOP = " + sumNoOOP); | |
} | |
static class SumOOP { | |
int a; | |
int b; | |
public SumOOP(int a, int b) { | |
this.a = a; | |
this.b = b; | |
} | |
int compute() { return a + b; } | |
} | |
static class SumNoOOP { | |
int a; | |
int b; | |
public SumNoOOP(int a, int b) { | |
this.a = a; | |
this.b = b; | |
} | |
public int getA() { | |
return a; | |
} | |
public void setA(int a) { | |
this.a = a; | |
} | |
public int getB() { | |
return b; | |
} | |
public void setB(int b) { | |
this.b = b; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment