Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Cannot find symbol when creating instance of another class

Featured Replies

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.
352f6ld.png

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 by Mechagoober

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.

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;
    }
  
  
}

 

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.

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?

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 by Explv

32 minutes ago, Explv said:

:???: 

Please don't spread completely false information.

Yes you're right, pardon :feels:

  • Author

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.

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 by The Undefeated

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.