Issue
I've been stuck on this problem for a while now. It's for a school assignment, our lector provided us with a ForestSimulation.java file, that calls for a tree.getPosition().x, as seen here:src="https://i.stack.imgur.com/Wv2rv.png" alt="tree.getPosition().x" />
We are told to make the methods that are needed, so I've made a Tree class aswell as a Birch class.
Yet I feel that no matter how I declare the x and y-values I can't figure to make it work.
I've tried a non abstract getPosition, and calling this.x in the method body. I've tried (as in SS) to make it an abstract method. But nothing seems to work.
Please help <3
Solution
You are trying to match a call like
tree.getPosition().x
but the method you put into your Tree class is
void getPosition() { ... }
so this method will never return a point that has x and y coordinates. Change this method into
Point getPosition() { ... }
Answered By - Hiran Chaudhuri
Answer Checked By - Cary Denson (JavaFixing Admin)