Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. Exception in thread "main" java.lang.Error: Unresolved compilation problems:
  2. Cannot instantiate the type Calculator2Service
  3. The method getCalculator2Port() is undefined for the type Calculator2Service
  4.  
  5. at com.theopentutorials.ws.calc2.client.Calc2Client.main(Calc2Client.java:13)
  6.  
  7. package com.theopentutorials.ws.calc2.client;
  8.  
  9. import com.theopentutorials.ws.calc2.*;
  10.  
  11. public class Calc2Client {
  12.  
  13. /**
  14. * @param args
  15. */
  16. public static void main(String[] args) {
  17. int a = 10;
  18. int b = 12;
  19. Calculator2Service calcService = new Calculator2Service();
  20. Calculator2 calc = calcService.getCalculator2Port();
  21. System.out.println(a + " + " + b + " = " + calc.add(a, b));
  22. System.out.println(a + " - " + b + " = " + calc.sub(a, b));
  23.  
  24. }
  25.  
  26. }
  27.  
  28. public interface Calculator2 {
  29.  
  30. public double add(double a, double b);
  31. public double sub(double a, double b);
  32. }
  33.  
  34. Calculator2 getCalculator2Port(){
  35. Calculator2 c = new Calculator2(){
  36. public double add(double a,double b){
  37. return(a+b);
  38. }
  39.  
  40. public double sub (double a, double b){
  41. return(a-b);
  42. }
  43. }
  44. return(c);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement