CDE
This commit is contained in:
parent
518da4a923
commit
764da6cbbb
6144 changed files with 83610 additions and 11 deletions
7
Task/Abstract-type/C++/abstract-type.cpp
Normal file
7
Task/Abstract-type/C++/abstract-type.cpp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class Abs {
|
||||
public:
|
||||
virtual int method1(double value) = 0;
|
||||
virtual int add(int a, int b){
|
||||
return a+b;
|
||||
}
|
||||
};
|
||||
9
Task/Abstract-type/C-sharp/abstract-type.cs
Normal file
9
Task/Abstract-type/C-sharp/abstract-type.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
abstract class Class1
|
||||
{
|
||||
public abstract void method1();
|
||||
|
||||
public int method2()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
13
Task/Abstract-type/Common-Lisp/abstract-type-1.lisp
Normal file
13
Task/Abstract-type/Common-Lisp/abstract-type-1.lisp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
(defgeneric kar (kons)
|
||||
(:documentation "Return the kar of a kons."))
|
||||
|
||||
(defgeneric kdr (kons)
|
||||
(:documentation "Return the kdr of a kons."))
|
||||
|
||||
(defun konsp (object &aux (args (list object)))
|
||||
"True if there are applicable methods for kar and kdr on object."
|
||||
(not (or (endp (compute-applicable-methods #'kar args))
|
||||
(endp (compute-applicable-methods #'kdr args)))))
|
||||
|
||||
(deftype kons ()
|
||||
'(satisfies konsp))
|
||||
10
Task/Abstract-type/Common-Lisp/abstract-type-2.lisp
Normal file
10
Task/Abstract-type/Common-Lisp/abstract-type-2.lisp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
(defmethod kar ((cons cons))
|
||||
(car cons))
|
||||
|
||||
(defmethod kdr ((cons cons))
|
||||
(cdr cons))
|
||||
|
||||
(konsp (cons 1 2)) ; => t
|
||||
(typep (cons 1 2) 'kons) ; => t
|
||||
(kar (cons 1 2)) ; => 1
|
||||
(kdr (cons 1 2)) ; => 2
|
||||
11
Task/Abstract-type/Common-Lisp/abstract-type-3.lisp
Normal file
11
Task/Abstract-type/Common-Lisp/abstract-type-3.lisp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
(defmethod kar ((n integer))
|
||||
1)
|
||||
|
||||
(defmethod kdr ((n integer))
|
||||
(if (zerop n) nil
|
||||
(1- n)))
|
||||
|
||||
(konsp 45) ; => t
|
||||
(typep 45 'kons) ; => t
|
||||
(kar 45) ; => 1
|
||||
(kdr 45) ; => 44
|
||||
27
Task/Abstract-type/D/abstract-type.d
Normal file
27
Task/Abstract-type/D/abstract-type.d
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import std.stdio;
|
||||
|
||||
class Foo {
|
||||
// abstract methods can have an implementation for
|
||||
// use in super calls.
|
||||
abstract void foo() {
|
||||
writeln("Test");
|
||||
}
|
||||
}
|
||||
|
||||
interface Bar {
|
||||
void bar();
|
||||
|
||||
// Final interface methods are allowed.
|
||||
final int spam() { return 1; }
|
||||
}
|
||||
|
||||
class Baz : Foo, Bar { // Super class must come first.
|
||||
override void foo() {
|
||||
writefln("Meep");
|
||||
super.foo();
|
||||
}
|
||||
|
||||
void bar() {}
|
||||
}
|
||||
|
||||
void main() {}
|
||||
3
Task/Abstract-type/Delphi/abstract-type-1.delphi
Normal file
3
Task/Abstract-type/Delphi/abstract-type-1.delphi
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
TSomeClass = class abstract (TObject)
|
||||
...
|
||||
end;
|
||||
13
Task/Abstract-type/Delphi/abstract-type-2.delphi
Normal file
13
Task/Abstract-type/Delphi/abstract-type-2.delphi
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
type
|
||||
TMyObject = class(TObject)
|
||||
public
|
||||
procedure AbstractFunction; virtual; abstract; // Your virtual abstract function to overwrite in descendant
|
||||
procedure ConcreteFunction; virtual; // Concrete function calling the abstract function
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
procedure TMyObject.ConcreteFunction;
|
||||
begin
|
||||
AbstractFunction; // Calling the abstract function
|
||||
end;
|
||||
3
Task/Abstract-type/E/abstract-type-1.e
Normal file
3
Task/Abstract-type/E/abstract-type-1.e
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
interface Foo {
|
||||
to bar(a :int, b :int)
|
||||
}
|
||||
9
Task/Abstract-type/E/abstract-type-2.e
Normal file
9
Task/Abstract-type/E/abstract-type-2.e
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
interface Foo guards FooStamp {
|
||||
to bar(a :int, b :int)
|
||||
}
|
||||
|
||||
def x implements FooStamp {
|
||||
to bar(a :int, b :int) {
|
||||
return a - b
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue