A student wanted to access MyNeighborhood in hopes of designing their own method in painterPlus that accesses the attribute (may not exist or be accessible by students or teachers?) MyNeighborhood.getPaintBuckets(). We tried a few variations to access attributes of MyNeighborhood without success but the syntax error cannot find symbol getPaintBucket made us wonder if it is a matter of hacking/guessing the method name.
@lmorr - It is exciting to hear that students are investigating how to implement other methods. If possible, could you share a code snippet? This may help answer your question and give relevant suggestions.
In the meantime, have you looked through the documentation in Code Lab?
I found a UML for neighborhood, but not MyNeighborhood. I hope this helps.
Sylvia
Hi Sylvia,
Thank you for responding. I am responding directly (instead of in the forum) because I think I didn’t ask my student’s question well. The documentation tab did give a very thorough description of the methods in Painter. What my student wanted is methods in Neighborhood or in MyNeighborhood. In particular he wanted to be able to know how many paint buckets were in a given instance of a MyNeighborhood using an access method. He did write code for navigation of a PainterPlus around the streets and a counter variable to keep track of how many there were. He wanted to know before navigating so he could end navigation when all were collected without finishing the navigation.
The answer to can we access methods in the “hidden” Neighborhood class, or see a UML for it is interesting to one student out of my seven and we will move on.
@lmorr thanks for asking this question - it sounds like your students are coming up with some innovative solutions!
To start, MyNeighborhood.java
is actually a file that your students are writing in, typically. This screenshot shows what students typically start with (because Code.org gives them some starter code with a class MyNeighborhood.java
as the class with the main
method.
Again, student’s could rename this class something else, you just need a main
method to run your code somewhere!
I do hear what your student is saying about they can see “The Neighborhood” and they are thinking computationally - they are thinking “This Neighborhood could be represented as a class an object with attributes like numberOfBuckets
”. That is actually great thinking! And a great example of using object orientated programming to design software! That is awesome! …
… and it is not quite how our tools are designed
So, the short answer is, no, there is no way “hidden code” that could tell the students exactly how many buckets are in a Neighborhood. Your student’s solution of wondering around the neighborhood until they have covered every space is actually a pretty good solution to this problem.
If you want to go deeper, the Neighborhood your students see (with the grass, sidewalk, buckets, etc.) are actually a 2D grid of JSON objects that describe what the square looks like and, if there is a bucket there, how much paint. Again, this is not a Java file that is hidden as much as a tool we use to represent the graphics on the page.
That might be a longer answer than you expected, but bottom line, I love how your student is thinking in terms of objects and classes and seeing how the Neighborhood could be represented in Java!
Thank you for these details about the Neighborhood, Kaitie! I have had students wanting to control the buckets and obstacles in the neighborhood also. It is a good discussion point to talk about what the Painter can and can’t do, and I’m glad to have these details to help fill in the gaps.