mirror of
https://onedev.site.tesses.net/crosslang/crosslang-tutorials
synced 2026-09-30 15:44:12 +00:00
First commit
This commit is contained in:
@@ -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"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
func main(args)
|
||||
{
|
||||
var cls = new Times(6,7);
|
||||
cls.Print();
|
||||
}
|
||||
@@ -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