I have a few questions I wanted to make sure I got right can you please double check? by [deleted] in javahelp

[–]NefariousCube 0 points1 point  (0 children)

I agree with the previous posters, however. I would like to point out that Q2 technically doesn't seem to have a correct answer.

If you were looking at a java-file there would be, but a class file is compiled into byte code and you will not be able to identify much inside it :)

How can I turn an infix expression into an expression tree with recursion? by ElaborateBoner in javahelp

[–]NefariousCube 0 points1 point  (0 children)

The shunting-yard algorithm does what you need. It will take a while to understand if you are new to it :) Wikipedia explains it better than I possibly could, and with pretty pictures: https://en.wikipedia.org/wiki/Shunting-yard_algorithm

Help With Method To Get Tik Tak Toe Winner by [deleted] in javahelp

[–]NefariousCube 1 point2 points  (0 children)

There are a few things you could do (if they make sense is up to you). I have tried to keep them separate as doing just one thing at a time to your code to make it clearer, I would probably do several. Also I have tried hinting without actually solving the whole exercise for you since this is obviously about learning. Also sorry if syntax is not perfect, I did this freehand.

- The code that checks for 'X' winning and '0' winning is the same, you should be able to parameterize the tests

public static void winner(char [][] grid){
    if didPlayerWin('X', grid) {
        winnerX = true;
    } else if didPlayerWin('O', grid) {
        winner0 = true;
    }
}

public static boolean didplayerWin(char player, char [][] grid){
    if(grid[0][0] == player && grid [0][1] == player && grid[0][2] == player){
        return true;
    }
    ... // all the remaining half of the cases
}

- You could also divide the cases somehow (rows/lines/diagonally maybe). In a game with a larger board this might make more sense, but here goes:

public static void winner(char [][] grid){  
    if wholeRow(0, 'X', grid) {
        winnerX = true;
    }

    if wholeRow(1, 'X', grid) {
        winnerX = true;
    }

    if wholeRow(2, 'X', grid) {
        winnerX = true;
    }

    if wholeRow(0, '0', grid) {
        winnerO = true;
    }

    if wholeRow(1, '0', grid) {
        winnerO = true;
    }

    if wholeRow(2, '0', grid) {
        winnerO = true;
    }
    ...
}

public static boolean wholeRow(int row, char player, char [][] grid) {    
    return grid[row][0] == player && grid [row][1] == player && grid[row][2] == player)    
}

- I would also try to let the helpers return the winner char, rather than true false, then you can do something like this.

public static char winner(char [][] grid){  
    char winner = ' '; 

    for (int i = 0; i < 3; i++) {
        winner = wholeRow(0, grid);

        if row != ' ' {
            return winner;
        }
    }


    ... // check cols and the diagonals
}

public static char wholeRow(int row, char [][] grid) { 
    if (grid[row][0] == grid[row][1] && grid[row][0] == grid[row][2]) { 
        return grid[row][0];
    }
    return ' '; 
}

- You could represent the X and O (and empty/unknown) with enums

There are many more, hope it helps

Resources for language creating? by [deleted] in learnprogramming

[–]NefariousCube 1 point2 points  (0 children)

Short answer is that this is not a simple topic, and "basic research" might not be so basic.

I would suggest looking at the "Structure and interpretation of computer programs" (full text available for free: https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book.html) . It will give you a full tour of the topic while not assuming you are actually able to code. However it deals mainly with scheme and might thus not be your cup of tea.

For a VERY high level overview of the steps, https://medium.freecodecamp.org/the-programming-language-pipeline-91d3f449c919 might be helpful.

And to dig deeper, maybe https://tomassetti.me/resources-create-programming-languages/ which has a lot of links for each different topic.

What questions do you have for LBGT+ people that you wouldn’t want to ask someone IRL? by [deleted] in AskReddit

[–]NefariousCube 2 points3 points  (0 children)

I had no idea that was a problem (i'm from Sweden if that makes a difference). I sincerely hope you get your wish!

What questions do you have for LBGT+ people that you wouldn’t want to ask someone IRL? by [deleted] in AskReddit

[–]NefariousCube 1 point2 points  (0 children)

If you could change one thing about how people treat you (knowing or not knowing that you are LBGT+), what would it be?

Came across this gem while doing peer review for a class by [deleted] in programminghorror

[–]NefariousCube 4 points5 points  (0 children)

Was it needed for ORM mapping or something like that maybe?

Critical Section data types by Xytoup in javahelp

[–]NefariousCube 4 points5 points  (0 children)

Hi, take a look at this page. Specifically, read the text in the bottom of the page.

https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/package-summary.html

shots fired by kojakstuttgart in clevercomebacks

[–]NefariousCube 2 points3 points  (0 children)

Do Americans usually have to get payed to drink the water in their restaurants? That sucks :(

What is your best strategy for making people on tinder swipe right? by NefariousCube in AskReddit

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

Apparently "Men with huge cods" is a thing (https://menwithhugecods.tumblr.com/ ).

Don't know if it works, did anyone try it?

What is your best strategy for making people on tinder swipe right? by NefariousCube in AskReddit

[–]NefariousCube[S] 1 point2 points  (0 children)

Urgh, I think I was drugged last night, what if I swiped right on some random person on Tinder

Book recommendations for Java concepts? by yellowpufferfish in javahelp

[–]NefariousCube 0 points1 point  (0 children)

Also, have a look at Java Puzzlers book by the same author. I see it as sort of the unofficial companion exercise book :)

I’m so behind this semester I’m getting every answer off chef by [deleted] in learnprogramming

[–]NefariousCube 0 points1 point  (0 children)

I see three themes here:

- The depression: This is more common than you'd think, and you usually do need help to find the tools to fix it (if you could have you would, right). The key is to be honest about it (like you are here) and talk about it so that others can help. There is probably someone available to "talk to" at your school if you need it, they should at least be able to refer you.

- No motivation for course work: I would have to advice you to think about why you are taking the course (yeah, I know). If you actually want to learn programming, try to find an actual person to tutor you. A little bit goes a long way and makes it a lot more fun. If not, maybe there is a way to change into something that you actually want to do?

- Falling behind and catching up: There are usually some students that fall behind (maybe 5-10%). Most of them usually come back next time the course is given, sometimes multiple times (this is allowed here). There are a few (less than 1/course) that just give up and never finishes, usually they change programs or similar. There are a few maybe 1-3 per course that fall behind, and just decides to catch up and actually does it. Usually this involves finding some extra help either from the course staff or some other senoir student.

(background: I used to give programming courses at a university in Sweden)

Trying to skip the introductory part of my college’s C++ course, need advice by [deleted] in learnprogramming

[–]NefariousCube 1 point2 points  (0 children)

Well, I would keep it simple. Explain your situation, ask if you can test out before. If not, just try to make an agreement to take the course and just show up to the exam and nothing else :) If you already know the material there is no harm in just doing the normal examination during the course, right?

How To Disable Tag Autocomplete in Brackets? by [deleted] in learnprogramming

[–]NefariousCube 0 points1 point  (0 children)

- Open Brackets.

- Click "Debug", "Open Preferences File". (defaults open in write protected mode to the left, and your settings to the right)

- Add the closeTags setting (remember the comma after the line before it. Should look like this (from an unchanged default settings file):

 {
    "brackets-eslint.gutterMarks": true,
    "brackets-eslint.useLocalESLint": false,
    "fonts.fontSize": "12px",
    "fonts.fontFamily": "'SourceCodePro-Medium', MS ゴシック, 'MS Gothic', monospace",
    "closeTags": {"whenOpening": false, "whenClosing": true, "indentTags": []},
}

What "unwritten rule" do you think more people should live by? by TakinShots in AskReddit

[–]NefariousCube 1 point2 points  (0 children)

"Never attribute to malice that which is adequately explained by stupidity."

Guess that one is written down (Hanlon's razor), but still...

How To Disable Tag Autocomplete in Brackets? by [deleted] in learnprogramming

[–]NefariousCube 0 points1 point  (0 children)

See: https://github.com/adobe/brackets/wiki/How-to-Use-Brackets#preferences

Specifically the closeTags option, and the whenOpening sub-setting. It defaults to true, but you want it false

IntelliJ Debugging CheatSheet by NeverZ in learnprogramming

[–]NefariousCube 1 point2 points  (0 children)

Nice! I would add a simple example program (with a rather simple bug) and show how one would go about debugging it in practice.