23 lines
525 B
Plaintext
23 lines
525 B
Plaintext
import std::io;
|
|||
|
|
import shapes;
|
||
|
|
def main(): void {
|
||
|
|
var b := parcel{ n = 5 };
|
||
|
|
println($"{b.count} {b.twice} {b.label}");
|
||
|
|
b.label = 8;
|
||
|
|
b.bump();
|
||
|
|
println($"{b.count} {b.twice} {b.label}");
|
||
|
|
}
|
||
|
|
module shapes;
|
||
|
|
pub struct parcel { pub var n: i64; }
|
||
|
|
var parcel::count: i64 {
|
||
|
|
pub get => this.n;
|
||
|
|
set => this.n = value;
|
||
|
|
}
|
||
|
|
var parcel::twice: i64 {
|
||
|
|
pub get => this.n * 2;
|
||
|
|
}
|
||
|
|
pub var parcel::label: i64 {
|
||
|
|
get => this.n + 100;
|
||
|
|
set => this.n = value;
|
||
|
|
}
|
||
|
|
pub def parcel::bump(&mut this): void { this.count = this.count + 1; }
|