✅ Confused by constant errors regarding class extension.
Hi all, for my uni course, I need to code a game. I have chosen TicTacToe, but it needs to use different design elements (Factory/Template/Strategy) the more that are successfully implemented are better. I have what I think is correct implementation of my Template method classes, but I can't get the rest of the program to talk to the methods within the extended classes. It throws up the error that an object must be passed to them, but I don't want to pass an object to it, I just want the method to run when it is called by another method/class. I have attached two images that show the issue I am running into - this is a problem amongst the whole program, but its the same error. What have I done wrong? I also don't know how to paste code into this, without it looking weird.
Thanks for your help - I am super stressed.
11 Replies
The error is clear
DisplayOptions()
is an instance method
Thus, it requires an instanceCan I change that? Or how do I fix it?
Either:
a) Use an instance of
WelcomeMenu
b) Make the method static
I can't make the method static though, because it is overriding the method from the 'Menu' class.
You have your answer, then
Ok, so how do I use an instance of WelcomeMenu? I thought I was doing that when I call to it in the first picture?
Thanks! How do I close a thread?
$close
Use the /close command to mark a forum thread as answered
Thanks