-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0621e4f
commit 838b330
Showing
5 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
class animal { | ||
public int a; | ||
protected int b; | ||
private int c; | ||
|
||
public animal init(int a, int b, int c) { | ||
self(a, b, c); | ||
} | ||
public int get_c() { return this.c; } | ||
public void set_c(int x) {this.c = x; } | ||
|
||
private void baz(){} | ||
protected void bar(){ this.baz(); } | ||
public void foo(){} | ||
}; | ||
|
||
class dog : animal { | ||
public int d; | ||
private int e; | ||
|
||
public dog init(int a, int b, int c, int d, int e) { | ||
super(a, b, c); | ||
self(d, e); | ||
} | ||
public int get_b() { return this.b; } | ||
public void set_b(int x) {this.b = x; } | ||
public int get_e() { return this.e; } | ||
public void set_e(int x) {this.e = x; } | ||
|
||
private void f1(){} | ||
public void f2(){ this.foo(); this.bar(); this.f1(); } | ||
}; | ||
|
||
void main () { | ||
dog my_dog = new_dog(1,2,3,4,5); | ||
|
||
int x = 0; | ||
x = my_dog.a; | ||
x = my_dog.d; | ||
x = my_dog.get_b(); | ||
x = my_dog.get_c(); | ||
x = my_dog.get_e(); | ||
|
||
my_dog.a = 0; | ||
my_dog.d = 0; | ||
my_dog.set_b(0); | ||
my_dog.set_c(0); | ||
my_dog.set_e(0); | ||
|
||
my_dog.foo(); | ||
my_dog.f2(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class d { | ||
public int a; | ||
|
||
public d init(int a) { | ||
self(a); | ||
} | ||
}; | ||
|
||
void foo(d x) {} | ||
d bar() { return new_d(5); } | ||
|
||
void main() { | ||
d my_d = bar(); | ||
foo(my_d); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class c1 { | ||
public int a; | ||
public c1 init(int x) { | ||
self(x); | ||
} | ||
}; | ||
class c2 : c1 { | ||
public int b; | ||
public c2 init(int x1, int x2) { | ||
super(x1); | ||
self(x2); | ||
} | ||
}; | ||
class c3 : c2 { | ||
public int c; | ||
public c3 init(int x1, int x2, int x3) { | ||
super(x1, x2); | ||
self(x3); | ||
} | ||
}; | ||
class c4 : c3 { | ||
public int d; | ||
public c4 init(int x1, int x2, int x3, int x4) { | ||
super(x1, x2, x3); | ||
self(x4); | ||
} | ||
}; | ||
class c5 : c4 { | ||
public int e; | ||
public c5 init(int x1, int x2, int x3, int x4, int x5) { | ||
super(x1, x2, x3, x4); | ||
self(x5); | ||
} | ||
}; | ||
|
||
void main() { | ||
c5 c = new_c5(1,2,3,4,5); | ||
int x = 0; | ||
x = c.a; | ||
x = c.b; | ||
x = c.c; | ||
x = c.d; | ||
x = c.e; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class human { | ||
public int x; | ||
public int y; | ||
public human init(int a, int b){ | ||
self(a,b); | ||
} | ||
}; | ||
|
||
class dog { | ||
public human owner; | ||
public dog init(human h) { | ||
self(h); | ||
} | ||
}; | ||
|
||
void main() { | ||
human h = new_human(5,6); | ||
dog d = new_dog(h); | ||
int t = d.owner.x; | ||
d.owner.y = t; | ||
} |