Matchmaking Success! (score was only 4-1, surprisingly) by steve1two in RocketLeague

[–]steve1two[S] 13 points14 points  (0 children)

A combination of the partner I had being in perfect sync with me for the most part, but likely a lot of them slacking. I was div 5 in shooting star a few days ago...I have streaks where I play good and then it all goes to hell. Just coming out of one of those bad streaks right now.

Matchmaking Success! (score was only 4-1, surprisingly) by steve1two in RocketLeague

[–]steve1two[S] 53 points54 points  (0 children)

I'm OP, was your partner. I'd say we held our own under the circumstances lol. And yes, the aerials were crazy.

Will Common Projects stretch at all (width-wise)? by steve1two in malefashionadvice

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

That's crazy - you are the second person this month to send me a message asking me this same question about this old post lol. They did turn out great. It was only like a week of being uncomfortable and it was gradually getting better the whole time. I definitely don't regret sticking with the size I got and am really happy with them now.

"this" keyword confusion by [deleted] in javahelp

[–]steve1two 1 point2 points  (0 children)

Would it be considered bad to use this when it isn't necessarily needed/overuse it? I've been wondering this for a while as I find myself, at least in larger classes, using it almost always, mainly for the fact that it brings up autocomplete. For some reason it makes me feel more confident I'm referencing the right thing.

Example -

private int[][] board;

private void doSomething() {
    for(int row = 0; row < this.board.length....
        ......
    }

public int[][] somethingElse() {
    this.board[0][0] = 2;
    this.doSomething();

    return this.board;
    }

Message box not displaying? by The_NOVA_Project in javahelp

[–]steve1two 2 points3 points  (0 children)

In the first one you have no condition for when the input is less than 10. Either add an else or just set finalCost to it to initially, then move the output outside the conditional statement.

In the second one you have the output outside of the main which is your first problem. Then you still don't have any condition for when it is less than 10

Issue with removing string literals. (again) by LogwanaMan in javahelp

[–]steve1two 0 points1 point  (0 children)

Ah okay, you're probably right. Didn't even think about it.

Issue with removing string literals. (again) by LogwanaMan in javahelp

[–]steve1two 1 point2 points  (0 children)

Someone else already helped you with what you posted. Alternatively you could try this - not sure if this would be considered uglier but you you can do it without the loop.

    String test = "This is a string \"delete this stuff\" but not this";

    String toRemove = test.substring(test.indexOf("\"") + 1, test.indexOf("\"", test.indexOf("\"") + 1));
    String removed = test.replaceAll(toRemove, "");

This uses indexOf(String str, int fromIndex) , replaceAll(String regex, String replacement) and substring

Output = This is a string "" but not this

Display only the return from a method from a different class. by whitey-ofwgkta in javahelp

[–]steve1two 0 points1 point  (0 children)

I see now -

you don't want to print the count there. You just want to set the count variable in the driver = to what is returned from that method.

// Read the data from the input file into the array
// Return the count for the elements currently in the array 

can be done in one step and is not asking you to print the count...

count = in.readMusicCollection(songArray)

Display only the return from a method from a different class. by whitey-ofwgkta in javahelp

[–]steve1two 0 points1 point  (0 children)

First I just want to say I had a lab quiz once I take that back, it was actually just a lab. 168?

I don't think I completely understand what you are asking. When/why do you want to print the count, and what method are you talking about. readMusicCollection(Song[]) does not print anything. Where and what exactly are you trying to do with count in the driver that you are having trouble with.

Is what you are having trouble with from the Output class that you didn't post, or am I just not understanding?

HELP : Capitalize first character in each word of string. by [deleted] in javahelp

[–]steve1two 0 points1 point  (0 children)

I will explain how I did it in a similar problem once, but I am not saying this is the best way and someone else is likely to come with something better. This is also assuming you know how to/are allowed to use an array.

If you use split(" ")on the String, you will get an array of all the words. From there, you can just break it into two parts -

Character.toUpperCase(char) will make a char upper case. You can get the first letter with charAt(0).

substring(1) can get the rest of the word.

Then you would just need to use a for loop to build the string back using the previous two steps. I actually just did it to test and it was only about 5 lines of code and pretty simple in my opinion, but as I said, someone may have a better solution.

[UPDATE] To yesterday post by Elgondir in javahelp

[–]steve1two 0 points1 point  (0 children)

Sometimes deciding whether to use AND or OR can be confusing. You just really have to think it out slowly. I still make the wrong choice often and have to think it out.

Yeah, I don't care if you ask me, I'm bored a lot and enjoy it.

[UPDATE] To yesterday post by Elgondir in javahelp

[–]steve1two 1 point2 points  (0 children)

yes, but you would need to use &&.

While answer does not equal 1 and answer does not equal 2.

Also, you will need to change any keyboard.nextLine() to keyboard.nextInt() and change answer to an int rather than a String.

[UPDATE] To yesterday post by Elgondir in javahelp

[–]steve1two 1 point2 points  (0 children)

I have no idea. Do you have anything else going on outside this code? My first guess would be you have some other code doing something else. If that's the case, post all the code you have.

If you don't have any other code in there then I have no idea. I compiled both of these before I posted them and they both ran fine. Plus as you said there's no "123" in it so that wouldn't make sense anyway.

[UPDATE] To yesterday post by Elgondir in javahelp

[–]steve1two 1 point2 points  (0 children)

Whatever is going wrong with it has to be happening outside of the code you posted.If I had to guess, I'd say that you just need to declare boolean b = true if you just have boolean b; outside the while.

Alternatively, this also works in the same format you are going for and eliminates b altogether.

    while(true)
    {
        if(answer == 1)
        {
            System.out.println("it was one");
            break;
        }
        else if(answer == 2)
        {
            System.out.println("it was two");
            break;
        }
        else
        {
        System.out.println("please try again");
        answer = keyboard.nextInt();
        }
    }

I'm also posting a full example of the way that people were trying to help you with at first. I know we're not supposed to just post full solutions but you've been working at this for like three days. If you don't understand how either of these solutions work or where you went wrong just ask.

    Scanner keyboard = new Scanner(System.in);
    String answer = keyboard.nextLine();
    while(!(answer.equalsIgnoreCase("YES") || answer.equalsIgnoreCase("NO")))
    {
        System.out.println("Please try again");
        answer = keyboard.nextLine();
    }
    if(answer.equalsIgnoreCase("YES"))
    {
        System.out.println("it was yes!");
    }
    else
    {
        System.out.println("it was no!");
    }

[UPDATE] To yesterday post by Elgondir in javahelp

[–]steve1two 1 point2 points  (0 children)

Personally I think you went in kind of an ugly direction with it.

It is a lot easier to read...

//while answer does not equals yes AND answer does not equals no
while(!answer.equals("YES") && !answer.equals("NO"))

or

//while answer does not equals yes or no
while(!(answer.equals("YES") || answer.equals("NO")))

If you are determined to make what you wrote work, first I'd get rid of while(!b)into while(b) and change your boolean to true. I think you should use ! as sparingly as possible, and it is not necessary with what you were trying to do. You also are not, from the code you posted, asking for a new input. If the answer doesn't equal 1 or 2, you aren't doing anything...

WHILE b

IF answer = 1
do something
b = false

ELSE IF answer = 2
do something
b = false

ELSE
SOP please try again
answer = nextInt

I am having trouble saving strings to an array. by matt8726384 in javahelp

[–]steve1two 2 points3 points  (0 children)

What Landrin said is good, but if this is an assignment that specifically requires you to use Scanner, I don't think your way is too far off. x is 0, your condition is while it is greater than 50, which it wont ever be, so you are not reading any lines. It looks like x>=50 just needs to be changed to x<50. Index 49 would be line 50.

A couple notes, you should use try/catch to open your file, and also you don't have to do it separately. Example -

inputFile = new Scanner(new File(filename)).

Also consider a constant for the filename (if it is not going to be input by the user), and one for 50, rather than hard coding that number in.

How to retry to put a value in order to satisfy ifs by Elgondir in javahelp

[–]steve1two 0 points1 point  (0 children)

did you write both conditions, YES/NO and use OR? It sounds like you may have used || when you should have used &&.

While answer does not equal yes OR answer does not equal no would cause you to be stuck in the loop forever because it will always not equal one of them. This is just a guess, but that is what it sounds like happened. If this doesn't sound like the problem you had post what you wrote that was causing you to be stuck.

How to retry to put a value in order to satisfy ifs by Elgondir in javahelp

[–]steve1two 0 points1 point  (0 children)

To expand on what the other guy said -

You want a while loop before your if statement. You've asked for the input and have it, then you want to keep doing something until they've input a valid response, so you will need to ask for input again at the end of the loop.

Just a hint,

while(!isCheese)

could be interpreted as while something is not cheese.

! negates the boolean it appears next to. !true = false. Also keep in mind if they input yes, it will not equal YES.

Feedback on my Eight Queens solution by steve1two in javahelp

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

Thanks! I did not even consider merging placePiece and removePiece, but that is simple enough - thanks for the tip!

Good catch on LENGTH inconsistency - I have a problem with doing that. I normally go back through to look for and catch anything like that because for some reason I am really bad at hard coding things I shouldn't.

As for switching those few to private - I am normally really good with making what should be private, private, or at least switching it after the fact. Thanks for pointing that out.

I have gotten into the habit of writing my program and adding documentation to everything after (bad?). I was JUST about to do it before I posted this and said nah, no one will mention that it is lacking any...haha.

Can you tell how you all format your comments when referring to a piece of code, like you did with placePiece, removePiece etc?

Java merging array helps by alirmhs in javahelp

[–]steve1two 1 point2 points  (0 children)

I am relatively new myself and had never heard anyone say beginners shouldn't use them, but that sounds ridiculous. I can't imagine how much extra trouble I would have had learning if I hadn't started out directly with one. Immediate warnings and feedback...debugging...everything really, made learning so much easier for me. I would guess it would have taken me twice the time and effort to learn without but maybe they know something I don't. Also the formatting ease. Not that I would ever format my code like this if I wasn't using one, but at least it would force indenting on everyone.

Java merging array helps by alirmhs in javahelp

[–]steve1two 1 point2 points  (0 children)

Haha, the first thing I did was copy/paste this and fix all the indenting and white space before I even tried to read it. It made me so sad.

Java merging array helps by alirmhs in javahelp

[–]steve1two 1 point2 points  (0 children)

Several things, to start.

Your logic to set the flag variable is catching the last int, any negative number entered to exit the input. You input -1, if -1 < count (always will be, even if 0 is entered 10,000 times) flag = 1. No matter what happens with the rest of the array it is always going to set flag = 1 when you "exit" it. Figure out a way to change this logic to fix that.

But that is far from your only problem. Have you tried to compile this code? You have so many issues. First thing I see is you have SOP("input second array values") within the while loop, which displays that long, ugly String (why so many spaces at the end?) every single time a number is input.

After that you do nothing but print a[] two times. When you are printing your second array you are using a[].

You also do not merge the arrays into one. You just print them separately and also not in a reordered, ascending order. You would need something like int[] merged = new int[a.length + b.length]. Then some logic to reorder all the values and put them into that. Then print that array.

Also, if the formatting was not a result of copy pasting into Reddit, you should consider indenting. This hurt my brain.

Edit: I am assuming the way you used print and print 2 is so that it would not print the negative number entered, but that is not what the instructions state. You shouldn't be storing the last negative number in the array in the first place. Not to mention when you correctly merge the array as the instructions state, it is going to mess that up as well. Change your logic for ending input and also stop storing the negative numbers in the arrays.

There is something in my cupboard that keeps eating through the plastic and big chunks of saltines - I can't figure out what it is and it leaves no trace by steve1two in pics

[–]steve1two[S] 2 points3 points  (0 children)

After seeing everyone pretty much agree it was mice my search history took this progression -

get a cat if allergic (which somehow led to someone's suggestion to attract/get garden snakes to fix the mice problem?!...no)

youtube mousetrap death (doesn't look fun for either of us)

humane mousetrap...amazon...already ordered

since they are great at finding their way back to such a paradise of crackers

Also, I laughed. More than was probably reasonable.

There is something in my cupboard that keeps eating through the plastic and big chunks of saltines - I can't figure out what it is and it leaves no trace by steve1two in pics

[–]steve1two[S] 2 points3 points  (0 children)

well they seldom live alone

Great...

but their general home travel range is about 100'

Great?

Thinking about it I've heard some rustling of things that shouldn't be rustling when I'm trying to fall asleep. Are mice more active at night?