mirror of
https://onedev.site.tesses.net/crosslang/crosslang-tutorials
synced 2026-02-08 09:05:47 +00:00
First commit
This commit is contained in:
10
3 Classes/cross.json
Normal file
10
3 Classes/cross.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"info": {
|
||||
"description": "Change Me",
|
||||
"short_name": "changeme",
|
||||
"short_name_pretty": "Change Me",
|
||||
"type": "console"
|
||||
},
|
||||
"name": "ClassExample",
|
||||
"version": "1.0.0.0-prod"
|
||||
}
|
||||
5
3 Classes/src/main.tcross
Normal file
5
3 Classes/src/main.tcross
Normal file
@@ -0,0 +1,5 @@
|
||||
func main(args)
|
||||
{
|
||||
var cls = new Times(6,7);
|
||||
cls.Print();
|
||||
}
|
||||
40
3 Classes/src/myclass.tcross
Normal file
40
3 Classes/src/myclass.tcross
Normal file
@@ -0,0 +1,40 @@
|
||||
class BaseClass {
|
||||
public abstract getOp();
|
||||
public abstract getA();
|
||||
public abstract getB();
|
||||
public abstract Print();
|
||||
|
||||
public ToString()
|
||||
{
|
||||
return $"{this.A} {this.Op} {this.B}";
|
||||
}
|
||||
}
|
||||
|
||||
class Times : BaseClass {
|
||||
private a;
|
||||
private b;
|
||||
public Times(a,b)
|
||||
{
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
public getA()
|
||||
{
|
||||
return this.a;
|
||||
}
|
||||
public getB()
|
||||
{
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public getOp()
|
||||
{
|
||||
return "*";
|
||||
}
|
||||
|
||||
public Print()
|
||||
{
|
||||
Console.WriteLine($"{this} = {this.a * this.b}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user