radko93 icon

odchylenie

radko93 | PRO | 02/05/13 05:49:56 PM UTC | 0 ⭐ | 255 👁️ | Never ⏰ | []
Java |

500 B

|

None

|

0 👍

/

0 👎

public class odchylenie {
    double s = 5;
    double z;
 
    public odchylenie(double z) {
        this.z = z;
    }
 
    void metoda1(double n) throws wyjatek  {
        if (Math.abs(s - n) > z) {
            throw new wyjatek("Stary, przesadziles, odchylenie masz");
        }
        else
            System.out.println("DZiala");
    }
    
    public void metoda2(double x) {
        try {
            metoda1(x);
        }
    catch(wyjatek e) {
    System.out.println(e.getMessage()); }
        
    }
    
 
    public static void main(String[] args) {
odchylenie test= new odchylenie(3);
test.metoda2(11);
    }
 
}

Comments