Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package ctu.mimdw.services;
  6.  
  7. import java.util.Date;
  8. import javax.jws.WebService;
  9. import javax.jws.WebMethod;
  10. import javax.jws.WebParam;
  11.  
  12. @WebService(serviceName = "SimpleService")
  13. public class SimpleService {
  14.  
  15.     /**
  16.      * Web service operation
  17.      */
  18.     @WebMethod(operationName = "currentdate")
  19.     public String currentdate() {
  20.         return new Date().toString();
  21.     }
  22.  
  23.     /**
  24.      * Web service operation
  25.      */
  26.     @WebMethod(operationName = "capitalize")
  27.     public String capitalize(@WebParam(name = "string") String string) {
  28.         return string.toUpperCase();
  29.     }
  30.  
  31.     /**
  32.      * Web service operation
  33.      */
  34.     @WebMethod(operationName = "sqrt")
  35.     public double sqrt(@WebParam(name = "number") double number) {
  36.         return Math.sqrt(number);
  37.     }
  38.  
  39.     /**
  40.      * Web service operation
  41.      */
  42.     @WebMethod(operationName = "compute")
  43.     public String compute(@WebParam(name = "operator") char operator, @WebParam(name = "first") double first, @WebParam(name = "second") double second) {
  44.         switch (operator) {
  45.             case '+':
  46.                 return first + " + " + second + " = " +  (first + second);
  47.                
  48.             case '-':
  49.                 return first + " - " + second + " = " +  (first - second);
  50.                
  51.             case '*':
  52.                 return first + " * " + second + " = " +  (first * second);
  53.                
  54.             case '/':
  55.                 return first + " / " + second + " = " +  (first / second);                
  56.         }
  57.  
  58.         return "BAD OPERAND! Allowed operands are +,-,*,/";
  59.     }
  60.    
  61.    
  62.    
  63.    
  64.  
  65.    
  66.  
  67.    
  68.    
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement