Jump to content

help on java.util.timer


Recommended Posts

Posted

I cannot seem to get past this error

first get Error:(38, 5) java: cannot find symbol
  symbol:   class Timer
  location: class Main.GEMaster

 

public class GEMaster extends Script {

    long Timer;
    Area shopArea = new Area(2953, 3205, 2960, 3202);
    Area grandexchangeArea = GRAND_EXCHANGE;
    Area tradingArea = VARROCK_WEST;
    static String Status = "Normal";
    boolean GotTradeOffer;
    Timer logTimer;
    Timer updateTimer;
    int numberofWSB;
    int numberofWLB;
    int numberofMSB;
    int numberofMLB;
    int numberofSA;
    int coinsinbank;

if i use import java.util.Timer;  i get Error:(51, 20) java: no suitable constructor found for Timer(int) 
    constructor java.util.Timer.Timer(boolean) is not applicable
      (argument mismatch; int cannot be converted to boolean)
    constructor java.util.Timer.Timer(java.lang.String) is not applicable
      (argument mismatch; int cannot be converted to java.lang.String)

 

 

so I add 

import java.util.Timer start;

I end up getting  Error:(21, 23) java: ';' expected noob coder buy the way just need a point in the way


 

 

Posted (edited)

Yes you need:

import java.util.Timer;

Wherever you are instantiating the Timer, you're doing it wrong.

Check the Java docs for the Timer class.

And follow some basic Java tutorials.

Also use a proper Java IDE, it will highlight where and what your errors are in your code.

Edited by Explv
Posted
7 minutes ago, Explv said:

Yes you need:

import java.util.Timer;

Wherever you are instantiating the Timer, you're doing it wrong.

Check the Java docs for the Timer class.

And follow some basic Java tutorials.

Also use a proper Java IDE, it will highlight where and what your errors are in your code.

thank you and all the error is in this part

 

@Override

public void onStart() throws InterruptedException {

    logTimer = new Timer(0);
    updateTimer = new Timer(0);

    Timer = System.currentTimeMillis();

    try {
        File file = new File(getDirectoryData()+"info.txt");

        if(!file.exists()) {
            file.createNewFile();
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}


@Override

public int onLoop() throws InterruptedException {

    if(logTimer.Passed(1)){
        log("Current money stock " + (int) inventory.getAmount("Coins"));
        log("Current money stock in bank " + coinsinbank);
        logTimer.reset();
    }
    if(updateTimer.Passed(30)){
        Update();
        updateTimer.reset();
        sleep(random(2000,3000));
    }

    if(Status == "Normal") {
        if (!GotTradeOffer) {
            if (tabs.open(Tab.INVENTORY) && !trade.isFirstInterfaceOpen()) {
                if (inventory.contains("Willow longbow") && inventory.contains("Willow shortbow") && inventory.contains("Maple shortbow") && inventory.contains("Maple longbow")) {
                    GoToShop();
                }
                if (!inventory.contains("Willow longbow") || !inventory.contains("Willow shortbow") || !inventory.contains("Maple shortbow") || !inventory.contains("Maple longbow")) {
                    GoToGe();
                }
            }
        } else if (GotTradeOffer) {
            Trade();
        }
    }else if (Status == "Muling"){
        WalktoTrade();
    }

    return 100;
}

 

 

Posted
1 minute ago, markdmp said:

thank you and all the error is in this part

 


@Override

public void onStart() throws InterruptedException {

    logTimer = new Timer(0);
    updateTimer = new Timer(0);

    Timer = System.currentTimeMillis();

    try {
        File file = new File(getDirectoryData()+"info.txt");

        if(!file.exists()) {
            file.createNewFile();
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}


@Override

public int onLoop() throws InterruptedException {

    if(logTimer.Passed(1)){
        log("Current money stock " + (int) inventory.getAmount("Coins"));
        log("Current money stock in bank " + coinsinbank);
        logTimer.reset();
    }
    if(updateTimer.Passed(30)){
        Update();
        updateTimer.reset();
        sleep(random(2000,3000));
    }

    if(Status == "Normal") {
        if (!GotTradeOffer) {
            if (tabs.open(Tab.INVENTORY) && !trade.isFirstInterfaceOpen()) {
                if (inventory.contains("Willow longbow") && inventory.contains("Willow shortbow") && inventory.contains("Maple shortbow") && inventory.contains("Maple longbow")) {
                    GoToShop();
                }
                if (!inventory.contains("Willow longbow") || !inventory.contains("Willow shortbow") || !inventory.contains("Maple shortbow") || !inventory.contains("Maple longbow")) {
                    GoToGe();
                }
            }
        } else if (GotTradeOffer) {
            Trade();
        }
    }else if (Status == "Muling"){
        WalktoTrade();
    }

    return 100;
}

 

 

 

Ok well apparently I *still* have to do this for you...

If you look at the docs for Timer:

https://docs.oracle.com/javase/8/docs/api/java/util/Timer.html

You will see there is no constructor that takes a number as the parameter.

There is an empty constructor though.

So just change new Timer(0) to new Timer()

..............

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...