I'm very new to Java but I'm trying to help me son learn it. Currently we have these classes:
Now my expectation is that elsewhere in the code we can say new water() or new land() to create those tiles. However, when compiling the "class" part of "public class water extends tile" highlights, and the error says:
and elsewhere saying "new water("");". But that doesn't appear to have any effect. I'm sure it's a simple Java thing that I don't know, but what's wrong here?
1 2 3 4 5 6 7 8 9 10 | public class tile extends GreenfootImage { public tile(String filename) { super (filename); } } |
1 2 3 4 5 6 7 8 9 10 | public class water extends tile { public void water() { super ( "water.png" ); } } |
1 2 3 4 5 6 7 8 9 10 | public class ground extends tile { public void ground() { super ( "ground.png" ); } } |
constructor tile in class tile cannot be applied to given types;
required: java.long.String
found: no arguments
reason actual and formal arguments lists differ in length
Now I've tried changing the code to say:
1 2 3 4 5 6 7 8 9 10 | public class water extends tile { public void water(String whatever) { super ( "water.png" ); } } |