A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
5
Task/Abstract-type/Groovy/abstract-type-1.groovy
Normal file
5
Task/Abstract-type/Groovy/abstract-type-1.groovy
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
public interface Interface {
|
||||
int method1(double value)
|
||||
int method2(String name)
|
||||
int add(int a, int b)
|
||||
}
|
||||
5
Task/Abstract-type/Groovy/abstract-type-2.groovy
Normal file
5
Task/Abstract-type/Groovy/abstract-type-2.groovy
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
public abstract class Abstract1 {
|
||||
abstract public int methodA(Date value)
|
||||
abstract protected int methodB(String name)
|
||||
int add(int a, int b) { a + b }
|
||||
}
|
||||
3
Task/Abstract-type/Groovy/abstract-type-3.groovy
Normal file
3
Task/Abstract-type/Groovy/abstract-type-3.groovy
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
public abstract class Abstract2 implements Interface {
|
||||
int add(int a, int b) { a + b }
|
||||
}
|
||||
15
Task/Abstract-type/Groovy/abstract-type-4.groovy
Normal file
15
Task/Abstract-type/Groovy/abstract-type-4.groovy
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
public class Concrete1 implements Interface {
|
||||
public int method1(double value) { value as int }
|
||||
public int method2(String name) { (! name) ? 0 : name.toList().collect { it as char }.sum() }
|
||||
public int add(int a, int b) { a + b }
|
||||
}
|
||||
|
||||
public class Concrete2 extends Abstract1 {
|
||||
public int methodA(Date value) { value.toCalendar()[Calendar.DAY_OF_YEAR] }
|
||||
protected int methodB(String name) { (! name) ? 0 : name.toList().collect { it as char }.sum() }
|
||||
}
|
||||
|
||||
public class Concrete3 extends Abstract2 {
|
||||
public int method1(double value) { value as int }
|
||||
public int method2(String name) { (! name) ? 0 : name.toList().collect { it as char }.sum() }
|
||||
}
|
||||
12
Task/Abstract-type/Groovy/abstract-type-5.groovy
Normal file
12
Task/Abstract-type/Groovy/abstract-type-5.groovy
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
def c1 = new Concrete1()
|
||||
assert c1 instanceof Interface
|
||||
println (new Concrete1().method2("Superman"))
|
||||
|
||||
def c2 = new Concrete2()
|
||||
assert c2 instanceof Abstract1
|
||||
println (new Concrete2().methodB("Spiderman"))
|
||||
|
||||
def c3 = new Concrete3()
|
||||
assert c3 instanceof Interface
|
||||
assert c3 instanceof Abstract2
|
||||
println (new Concrete3().method2("Hellboy"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue