radko93

odchylenie

Feb 5th, 2013
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. public class odchylenie {
  2.     double s = 5;
  3.     double z;
  4.  
  5.     public odchylenie(double z) {
  6.         this.z = z;
  7.     }
  8.  
  9.     void metoda1(double n) throws wyjatek  {
  10.         if (Math.abs(s - n) > z) {
  11.             throw new wyjatek("Stary, przesadziles, odchylenie masz");
  12.         }
  13.         else
  14.             System.out.println("DZiala");
  15.     }
  16.    
  17.     public void metoda2(double x) {
  18.         try {
  19.             metoda1(x);
  20.         }
  21.     catch(wyjatek e) {
  22.     System.out.println(e.getMessage()); }
  23.        
  24.     }
  25.    
  26.  
  27.     public static void main(String[] args) {
  28. odchylenie test= new odchylenie(3);
  29. test.metoda2(11);
  30.     }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment