A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
28
Task/Abstract-type/Fantom/abstract-type.fantom
Normal file
28
Task/Abstract-type/Fantom/abstract-type.fantom
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
abstract class X
|
||||
{
|
||||
Void method1 ()
|
||||
{
|
||||
echo ("Method 1 in X")
|
||||
}
|
||||
|
||||
abstract Void method2 ()
|
||||
}
|
||||
|
||||
class Y : X
|
||||
{
|
||||
// Y must override the abstract method in X
|
||||
override Void method2 ()
|
||||
{
|
||||
echo ("Method 2 in Y")
|
||||
}
|
||||
}
|
||||
|
||||
class Main
|
||||
{
|
||||
public static Void main ()
|
||||
{
|
||||
y := Y()
|
||||
y.method1
|
||||
y.method2
|
||||
}
|
||||
}
|
||||
4
Task/Abstract-type/Genyris/abstract-type-1.genyris
Normal file
4
Task/Abstract-type/Genyris/abstract-type-1.genyris
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
class AbstractStack()
|
||||
def .valid?(object) nil
|
||||
|
||||
tag AbstractStack some-object # always fails
|
||||
8
Task/Abstract-type/Genyris/abstract-type-2.genyris
Normal file
8
Task/Abstract-type/Genyris/abstract-type-2.genyris
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
class StackInterface()
|
||||
def .valid?(object)
|
||||
object
|
||||
and
|
||||
bound? .enstack
|
||||
is-instance? .enstack Closure
|
||||
bound? .destack
|
||||
is-instance? .destack Closure
|
||||
9
Task/Abstract-type/Genyris/abstract-type-3.genyris
Normal file
9
Task/Abstract-type/Genyris/abstract-type-3.genyris
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
class XYZstack(Object)
|
||||
def .init()
|
||||
var .items ()
|
||||
def .enstack(object)
|
||||
setq .items (cons object .items)
|
||||
def .destack()
|
||||
var tmp (car .items)
|
||||
setq .items (cdr .items)
|
||||
tmp
|
||||
1
Task/Abstract-type/Genyris/abstract-type-4.genyris
Normal file
1
Task/Abstract-type/Genyris/abstract-type-4.genyris
Normal file
|
|
@ -0,0 +1 @@
|
|||
tag StackInterface (XYZstack(.new))
|
||||
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"))
|
||||
2
Task/Abstract-type/Julia/abstract-type.julia
Normal file
2
Task/Abstract-type/Julia/abstract-type.julia
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
abstract «name»
|
||||
abstract «name» <: «supertype»
|
||||
9
Task/Abstract-type/Logtalk/abstract-type.logtalk
Normal file
9
Task/Abstract-type/Logtalk/abstract-type.logtalk
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
:- protocol(datep).
|
||||
|
||||
:- public(today/3).
|
||||
:- public(leap_year/1).
|
||||
:- public(name_of_day/3).
|
||||
:- public(name_of_month/3).
|
||||
:- public(days_in_month/3).
|
||||
|
||||
:- end_protocol.
|
||||
Loading…
Add table
Add a link
Reference in a new issue