Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package kolos1;
- public class Kolos1 {
- public static void main(String[] args) {
- B b = new B();
- System.out.println(b.random());
- C c = new C(20);
- System.out.println(c.random());
- F f = new F();
- System.out.println(f.sum(15, 20.5));
- System.out.println(f.sum(15.7, 20));
- E e = new E()
- {
- public double sum(int x, double y)
- {
- return x + y;
- }
- };
- System.out.println(e.sum(100, 2.15));
- }
- }
- abstract class A
- {
- abstract int random();
- }
- class B extends A
- {
- int random()
- {
- return (int)(Math.random()*1000);
- }
- }
- class C extends A
- {
- int max;
- C(int max)
- {
- this.max = max;
- }
- int random()
- {
- return (int)(Math.random()*(max+1));
- }
- }
- interface D extends E
- {
- double sum(double x, int y);
- }
- interface E
- {
- double sum(int x, double y);
- }
- class F implements D
- {
- public double sum(double x, int y)
- {
- return sum(y, x);
- }
- public double sum(int x, double y)
- {
- return x + y;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement