Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
EPFL
IC 1
prog
serie-09
Commits
6fe28339
Verified
Commit
6fe28339
authored
Nov 19, 2021
by
Jonas Sulzer
🎓
Browse files
🐛
FIX: type errors
Signed-off-by:
Jonas Sulzer
<
jonas@violoncello.ch
>
parent
94dc9d56
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Ex_04/Typage.java
View file @
6fe28339
...
...
@@ -9,15 +9,16 @@ class Typage {
a
[
3
]
=
new
C
(
4
,
2
);
a
[
4
]
=
new
D
();
int
somme
=
0
;
System
.
out
.
println
(
a
[
1
].
getClass
());
for
(
int
i
=
0
;
i
<
a
.
length
;
i
++)
{
if
(
a
[
i
]
instanceof
D
)
{
System
.
out
.
println
(((
D
)
a
[
i
]).
d
);
}
else
{
if
(
a
[
i
]
instanceof
B
)
{
somme
=
somme
+
ma
(
a
[
i
]);
somme
=
somme
+
ma
(
(
B
)
a
[
i
]);
// otherwise a[i] isn't necessarily of type B required by ma()
if
(
a
[
i
]
instanceof
C
)
{
C
c
=
a
[
i
];
C
c
=
(
C
)
a
[
i
];
// otherwise a[i] isn't necessarily of type C required by mc()
c
.
mc
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment