Last active
August 29, 2015 14:15
-
-
Save eroltutumlu/b418697c44ac95720ddb to your computer and use it in GitHub Desktop.
Exception
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
package Sample; | |
public class Main { | |
public static void main(String[] args) { | |
Divide exp = new Divide(); | |
int Sonuc = exp.Divider(10, 5); | |
if(exp.getErrorFlag()) | |
{ | |
System.out.println(exp.ErrorMessage()); | |
} | |
else | |
{ | |
System.out.println(Sonuc); | |
} | |
} | |
} | |
class Divide { | |
//@Data encapsulation Access modifier | |
private boolean ErrorFlag; | |
private String ErrorMessage; | |
//@Getter | |
public boolean getErrorFlag() | |
{ | |
return ErrorFlag; | |
} | |
//@Getter | |
public String getErrorMessage() | |
{ | |
return ErrorMessage; | |
} | |
public int Divider(int a, int b) | |
{ | |
if(a < 0 || b < 0) | |
{ | |
this.ErrorFlag = true; | |
this.ErrorMessage = "Negatif değer girilemez."; | |
return 0; | |
} | |
if(b==0) | |
return 0; | |
else | |
return a/b; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment