Mechagoober Posted May 19, 2017 Share Posted May 19, 2017 (edited) I'm making a banking class along with my actual main class and I'm extending the GUI class as follows Banking extends WoodCutter Now, when I make an object of that class in my main as follows Banking bank = new Banking(); bank.banking(); I have a banking method in my Banking class However, I get these two errors when trying to make use of the bank method. I would be grateful for some help. Thanks! Edit: For further information I can get it to work if I just make the method inside the main, my point is I'm trying to figure out how to use classes but I'm not seeing what I am doing wrong. Edited May 19, 2017 by Mechagoober Quote Link to comment Share on other sites More sharing options...
Polymorphism Posted May 19, 2017 Share Posted May 19, 2017 Give use a bit more of your code, seeing structure would help tremendously for providing assistance. However, for starts lets not name your task bank. Rename it to something like banking -- what i usually do is a camelCase name of the class name for simplicity sake. so you would have Banking banking = new Banking(); Make sure your banking variable is a field and your instantiate it onStart() or whenever it should start. Set it to null initially. Quote Link to comment Share on other sites More sharing options...
Mechagoober Posted May 19, 2017 Author Share Posted May 19, 2017 Here is a paste bin of my code. I haven't used the banking field yet. Every time I try and do so I get a compile error "Cannot find symbol."https://pastebin.com/pEJeJf5Q Quote Link to comment Share on other sites More sharing options...
The Undefeated Posted May 19, 2017 Share Posted May 19, 2017 Pretty sure it isn't possible to extend your classes with the main class. Also don't use a while loop in your bank() method. If statement does the job. In your walk method you have double brackets in IF condition for no reason. What you should do is making a constructor in your bank class and pass the Methodprovider through it. No idea if I am explaining it right, here an example: Public class Banking { Methodprovider s; public Banking (MethodProvider s) { this.s = s; } public void bank() { // Here your banking method. } } public class Woodcutter extends Script { public int onLoop() { Banking banking = new Banking(this); banking.bank(); return 100; } } Quote Link to comment Share on other sites More sharing options...
Butters Posted May 19, 2017 Share Posted May 19, 2017 Basically what undefeated said. You can only extend Abstract classes and WoodCutter is not. If you want to make your code cleaner and put it in different classes that's great. You could try to use inheritance here to put different tasks in different classes and "control" via an abstract "Task" class (search in forums to find some examples), or can do as you do now via states. Try to do that Undefeated said and you should be ok. Pass me the Woodcutter object to banking and use the api methods there. Quote Link to comment Share on other sites More sharing options...
Apaec Posted May 19, 2017 Share Posted May 19, 2017 2 hours ago, nosepicker said: You can only extend Abstract classes This is not true! ----- As for the original issue, I'm not sure why you would need to extend your already script extending class. Please could you explain what exactly it is that you're trying to to? Quote Link to comment Share on other sites More sharing options...
Explv Posted May 19, 2017 Share Posted May 19, 2017 (edited) 3 hours ago, nosepicker said: Basically what undefeated said. You can only extend Abstract classes and WoodCutter is not. Please don't spread completely false information. Edited May 19, 2017 by Explv 1 Quote Link to comment Share on other sites More sharing options...
Butters Posted May 19, 2017 Share Posted May 19, 2017 32 minutes ago, Explv said: Please don't spread completely false information. Yes you're right, pardon Quote Link to comment Share on other sites More sharing options...
Mechagoober Posted May 19, 2017 Author Share Posted May 19, 2017 I am simply trying to make a GUI class and a WoodCutter class and am trying to call my GUI method into my WoodCutter class but everything I try and do gives me these two errors. Quote Link to comment Share on other sites More sharing options...
The Undefeated Posted May 19, 2017 Share Posted May 19, 2017 (edited) 1 hour ago, Mechagoober said: I am simply trying to make a GUI class and a WoodCutter class and am trying to call my GUI method into my WoodCutter class but everything I try and do gives me these two errors. Nice two errors. Edited May 19, 2017 by The Undefeated Quote Link to comment Share on other sites More sharing options...
Mechagoober Posted May 19, 2017 Author Share Posted May 19, 2017 DUDE. They are in the first post man.. I don't know what I am doing wrong. Everything looks fine lul Quote Link to comment Share on other sites More sharing options...