Homework 3

This commit is contained in:
Carlos Galindo 2020-01-15 22:32:25 +01:00
parent bf60a078d7
commit 0afc86ceeb
Signed by: kauron
GPG key ID: 83E68706DEE119A3
129 changed files with 3163 additions and 4316 deletions

View file

@ -0,0 +1,16 @@
// The number of parameters when overriding a method must be equal
class Other {
void action() {
write(10);
}
}
class Main extends Other {
void action(int num) {
write(num);
return num + 1;
}
void main() {}
}

View file

@ -0,0 +1,14 @@
// The return type when overriding a method must be equal
class Other {
void action() {}
}
class Main extends Other {
int action() {
write(10);
return 8;
}
void main() {}
}

View file

@ -0,0 +1,17 @@
// The type of parameters when overriding a method must match the overridden method
class Other {
void action(int num) {
write(num);
}
}
class Main extends Other{
void action(boolean name) {
if (name) {
writeln();
}
}
void main() {}
}

View file

@ -0,0 +1,16 @@
// Call method that has been overridden (both the new and old one)
class Other {
void method() {}
}
class Main extends Other {
void main() {
Other o;
method();
o = (Other) this;
o.method();
}
void method() {}
}