-
Notifications
You must be signed in to change notification settings - Fork 1
/
hehe.decaf
63 lines (58 loc) · 833 Bytes
/
hehe.decaf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Animal
{
string name;
int eattime;
int init()
{
name = "Animal";
}
int eat()
{
Print("I have eat for");
eattime = eattime+1;
Print(eattime);
Print("times");
return 0;
}
int p()
{
Print(name);
return 0;
}
}
class Chicken extends Animal
{
int init()
{
eattime = 1;
name = "Chicken";
return 3;
}
}
class Cow extends Animal
{
int init()
{
eattime = 0;
name = "Cow";
return 0;
}
}
int main(int argc, string argv)
{
Animal a;
Animal b;
int i;
a = New(Chicken);
b = New(Cow);
Print(a.init());
a.p();
a.eat();
b.init();
for (i=0; i<5; i=i+1)
{
b.p();
b.eat();
}
return 0;
}