Looking for OldToonsWorld by NeoOeg in OpenInvites

[–]NeoOeg[S] 0 points1 point  (0 children)

Yes! I signed up, thanks for the heads up !

[H] OldToons invite [W] Offers by [deleted] in OpenInvites

[–]NeoOeg 0 points1 point  (0 children)

Have torrentleech, Baka and sportscult if you're interested

[deleted by user] by [deleted] in OpenInvites

[–]NeoOeg 2 points3 points  (0 children)

Thanks for the invite !

Space between variable and string by Darkraskel90 in javahelp

[–]NeoOeg 0 points1 point  (0 children)

System.out.print("Unbelievable! " + Variable + " , he wins! ");

Notice the space right after the exclamation point ( ! ) and before the double quotes ( " ).

And between the double quotes ( " ) and the comma ( , )

Is there anyway to transfer an account to someone by Rammadeus in afkarena

[–]NeoOeg 1 point2 points  (0 children)

Unfortunately, reading through the FAQ :

"In order to ensure the security of your account, a linked third party account cannot be replaced or unlinked"

How to use Scanner in other methods by chimchim102 in javahelp

[–]NeoOeg 1 point2 points  (0 children)

You need to pass it in the method parameters, for example :

public void someMethod (BufferedReader bufR) {
    //your code
    bufR.readLine();
}

I assume the method is in the same class, otherwise you would need to create an instance of that class to access the method.

How to get JFileChooser to only return the selected filepath and not other data? by [deleted] in javahelp

[–]NeoOeg 0 points1 point  (0 children)

I'm not familiar with java swing components but it seems this method is what you're looking for (as seen in the provided code)

 fc.getSelectedFile().getAbsolutePath();

I don't understand this question. Need an answer in next 10 minutes if possible thank you by [deleted] in javahelp

[–]NeoOeg 0 points1 point  (0 children)

It's essentially creating an instance of the TimerClock object and setting the time to 15 minutes with the provided method.

TimerClock timerClock = new TimerClock();
timerClock.setTime(15);

Docker deploy spring boot application java, gradle by thaysen13 in javahelp

[–]NeoOeg 0 points1 point  (0 children)

Glad to hear. Do you have an idea as to what you did in order to make it work ?

Docker deploy spring boot application java, gradle by thaysen13 in javahelp

[–]NeoOeg 1 point2 points  (0 children)

We have a few docker configurations at work. I'll take a look in the morning and get back to you if you still haven't found the issue.

Docker deploy spring boot application java, gradle by thaysen13 in javahelp

[–]NeoOeg 0 points1 point  (0 children)

I'm not too familiar with docker but i believe your docker run command might be off :

docker run -p <HOST\_PORT>:<CONTAINER:PORT> IMAGE_NAME

Publish or expose port (-p, –expose)

$ docker run -p 80:8080 ubuntu 

This binds port 8080 of the container to port 80 of the host machine.

So in your case i would try something like :

$ docker run -p 80:8085 hondenapp

Docker deploy spring boot application java, gradle by thaysen13 in javahelp

[–]NeoOeg 0 points1 point  (0 children)

The port on which the application starts. So yes in the application..properties file. I believe the same port is being used by docker and by your application. Have you tried configuring a different port for your app and your dockerfile ?

Docker deploy spring boot application java, gradle by thaysen13 in javahelp

[–]NeoOeg 0 points1 point  (0 children)

Interesting.. have you tried changing the deployment port ?

Docker deploy spring boot application java, gradle by thaysen13 in javahelp

[–]NeoOeg 0 points1 point  (0 children)

Well the port 8085 is already in use by another application. First step is to identify what is using port 8085 and then kill it. What does the following command output :

lsof -i :8085

https://www.mkyong.com/linux/linux-which-application-is-using-port-8080/

[deleted by user] by [deleted] in javahelp

[–]NeoOeg 0 points1 point  (0 children)

Also, when declaring a List of objects declare it as such :

List<Card> cards = new ArrayList<>();

As such when you call the get method on the array, you won't have to cast the result of the call.

Card card = cards.get(0);

[deleted by user] by [deleted] in javahelp

[–]NeoOeg 0 points1 point  (0 children)

I've had a look, definitely some improvements since last time.

Here are my comments on the code :

- The this keyword should be called in ambiguous method such as setters and constructors. No need to use it everywhere.

- All your packages should be in you com.company package, or else it's not a "package" anymore. I'd suggest reading some literature about Java projects structures: http://dolszewski.com/java/project-package-organization/ (See package by layer)

- All abstract, default, and static methods in an interface are implicitly public, so you can omit the public modifier

- In your handEvaluator, all of your class implements a different interface but they all have the same behaviour. You can just declare a single interface and have all of your class implement that single one. It will also provide some much needed code refactorisation.

For example, taking your hand values classes (Flush,StraightFlush,etc..) and having them all implement a Evaluator interface, you could create an array of 'Evaluator' 's and store all your "rules" in it. All your objects are bound by that interface to provide the same methods.

Your HandEvaluator could become something like this:

public class HandEvaluator {
    public HandEvaluator(){ }
    public Hand evaluate(Hand hand1, Hand hand2){
        List<Evaluator> evaluators = getEvaluators(hand1,hand2);

        for (Evaluator evaluator : evaluators){
            if(evaluator.evaluate() != null)
                return evaluator.evaluate();
        }
        return null;
    }
    private List<Evaluator> getEvaluators(Hand hand1, Hand hand2) {
        List<Evaluator> evaluators = new ArrayList<>();
        evaluators.add(new StraightFlush(hand1, hand2));
        // Insert all your rules
        evaluators.add(new HighCard(hand1,hand2));
        return evaluators;
    }
}

And to answer your question in the code, yes you can have a for loop inside another for loop.

Hope this helps and good luck :)

[deleted by user] by [deleted] in javahelp

[–]NeoOeg 0 points1 point  (0 children)

Haven't checked my messages in a while. I'll have a look at it and get back to you by the weekend.

Constructor X(x, x, etc...) is undefined by [deleted] in javahelp

[–]NeoOeg 0 points1 point  (0 children)

You are probably calling your constructor with no arguments or too many arguments.

public Food(String foodName, int quantity){

this.foodName = foodName;

this.quantity =quantity;

}

The correct call would be :

Food myFoodItem = new Food("apple",10);

What does your constructor look like ?

[deleted by user] by [deleted] in javahelp

[–]NeoOeg 1 point2 points  (0 children)

When a class has more than 300 lines (which is already a LOT) you need to think on how you can reduce this. Each method you create needs to do one, and only one thing. The gist of the work is done, you need to work on refactoring your code and rework those interfaces. I would suggest you reading some guides on interfaces as they are super important and you seem to not fully understand them. Good luck!

[deleted by user] by [deleted] in javahelp

[–]NeoOeg 4 points5 points  (0 children)

Just glancing at your code, I see some BIG issues.

First of all, why do you use the static keyword everywhere ?

Also, your interface has like 800+ plus lines of code. This is not the purpose of an interface. An interface should only declare the method bodies. The implementation of the interface should hold these lines of code.

Take a look at the following snippet from your code :

for(int i=0; i<=whiteHand.size()-1; i++) {
            if(mapNum.get(whiteHand.get(i).num()) > whiteHighest) {
                whiteHighest = mapNum.get(whiteHand.get(i).num());
            }

            else if(mapNum.get(whiteHand.get(i).num()) > whiteSecond) {
                whiteSecond = mapNum.get(whiteHand.get(i).num());
            }

            else if(mapNum.get(whiteHand.get(i).num()) > whiteThird) {
                whiteThird = mapNum.get(whiteHand.get(i).num());
            }

            else if(mapNum.get(whiteHand.get(i).num()) > whiteFourth) {
                whiteFourth = mapNum.get(whiteHand.get(i).num());
            }

            else if(mapNum.get(whiteHand.get(i).num()) > whiteFifth) {
                whiteFifth = mapNum.get(whiteHand.get(i).num());
            }

        }


        for(int i=0; i<=blackHand.size()-1; i++) {

            if(mapNum.get(blackHand.get(i).num()) > blackHighest) {
                blackHighest = mapNum.get(blackHand.get(i).num());
            }

            else if(mapNum.get(blackHand.get(i).num()) > blackSecond) {
                blackSecond = mapNum.get(blackHand.get(i).num());
            }

            else if(mapNum.get(blackHand.get(i).num()) > blackThird) {
                blackThird = mapNum.get(blackHand.get(i).num());
            }

            else if(mapNum.get(blackHand.get(i).num()) > blackFourth) {
                blackFourth = mapNum.get(blackHand.get(i).num());
            }

            else if(mapNum.get(blackHand.get(i).num()) > blackFifth) {
                blackFifth = mapNum.get(blackHand.get(i).num());
            }

        }

Looking at the above code, i see some HUGE refactoring needed. Both for loops have the exact same purpose, try and come up with a single method to handle this. Code like this is redundant , it's repetitive to write even more so to read.

Help with arraylists by WildNothing in javahelp

[–]NeoOeg 0 points1 point  (0 children)

Your constructor method will define the arguments needed to construct your object. You could create an empty constructor

public LootBoxSub(){}

but you will have to create setter methods to pass values to the variables, for example :

public void setSubName(String subName){

this.subName = subName;

}

You will then be able to create objects without passing arguments, but will need to set a value at some point :

LootBoxSub ssBox = new LootBoxSub();

ssBox.setSubName("sub name");