Guest User

Untitled

a guest
Jun 13th, 2020
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. public class Main {
  2.     interface YouFace {
  3.         String getName();
  4.     }
  5.  
  6.     static class Posylatel<Y> {
  7.         Y you;
  8.  
  9.         Posylatel(Y you) {
  10.             this.you = you;
  11.         }
  12.  
  13.         public void say() {
  14.             System.out.printf("Poshol na huy %s\n", ((YouFace)you).getName());
  15.         }
  16.     }
  17.  
  18.     static class You implements YouFace {
  19.         private final String name;
  20.  
  21.         You(String name) {
  22.             this.name = name;
  23.         }
  24.  
  25.         @Override
  26.         public String getName() {
  27.             return name;
  28.         }
  29.     }
  30.  
  31.     public static void main(String[] args) {
  32.         var me = new Posylatel<YouFace>(new You("Pidor"));
  33.         me.say();
  34.     }
  35. }
Add Comment
Please, Sign In to add comment