Ejemplo n.º 1
0
        public int Tambah(int a, int b)
        {
            try
            {
                return(a + b);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                //secara default
                //throw new Exception(ex.Message) // pesan error secara default
                //throw new FaultException("pesan salah") // untuk meloloskan pesan yang dikirim ke client

                MathFault mf = new MathFault();
                mf.Kode  = "Input yang Anda Masukan Salah";
                mf.Pesan = "Masukan Input yang Benar";
                throw new FaultException <MathFault>(mf);
            }
        }
Ejemplo n.º 2
0
        //TKoordinat:nama methodnya, a,b = input seperti int.
        //Membuat koordinat hasil lalu menjumlahkan xa dengan xb, ya

        public Koordinat TKoordinat(Koordinat a, Koordinat b)
        {
            try
            {
                Koordinat hasil = new Koordinat();
                hasil.X = a.X + b.X;
                hasil.Y = a.Y + b.Y;
                return(hasil);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                //secara default
                //throw new Exception(ex.Message) // pesan error secara default
                //throw new FaultException("pesan salah") // untuk meloloskan pesan yang dikirim ke client

                MathFault mf = new MathFault();
                mf.Kode  = "Input yang Anda Masukan Salah";
                mf.Pesan = "Masukan Input yang Benar";
                throw new FaultException <MathFault>(mf);
            }
        }