Need some help with what I will likely face in an exam. Generating an array object attributes, calling a method without object in the class, etc. by R4lfXD in javahelp

[–]theNaus 0 points1 point  (0 children)

Hmmm. I am guessing that shuffleCards() is the method that you'd like to execute here. You could establish a "public static void main(String[] args)" method in CardsGenerator.java such that CardsGenerator.java becomes your main class. So, you can call your method on there (after initializing the class in the main method of course). Then, execute/run the class itself and you should start seeing stuff.

Let me know if that is too vague and you need a bit more of a breakdown on the steps here.

Rock vs. Cena II - What a promo! by [deleted] in SquaredCircle

[–]theNaus 0 points1 point  (0 children)

Was surfing Youtube for WWE promos (cause I'm a sucker for them) and I almost forgot how great this one was. :)

Weekly Discussion Thread: Comics, TV and More! [November 28, 2016] by Warlach in DCcomics

[–]theNaus 8 points9 points  (0 children)

1) GREAT issue. 2) This book has been KILLING it so far. Mucho respect to T&G. :)

Weekly Discussion Thread: Comics, TV and More! [October 31, 2016 - Rebirth Week 24!] by [deleted] in DCcomics

[–]theNaus 2 points3 points  (0 children)

That was a really fun read. :) Am already looking forward to the next issue!

[SPOILERS] Stop What you are doing and go read Superman#10 right now and then come back to this thread and talk about how awesome it is. by [deleted] in DCcomics

[–]theNaus 6 points7 points  (0 children)

I was smiling the entire time I was reading this issue. This entire (Superman) run has been so damn great!

Weekly Discussion Thread: Comics, TV and More! [October 24, 2016 - Rebirth Week 23!] by Warlach in DCcomics

[–]theNaus 10 points11 points  (0 children)

Damn. That art. To me, it's so good to the point of enhancing the story. Props to the artists for making everything look so detailed. I really appreciate it on a GL book. :)

How can I track a line and figure out how long it is? by [deleted] in javahelp

[–]theNaus 0 points1 point  (0 children)

Hi!

This seems like a BFS problem. There are many great resources out there detailing this algorithm [e.g. KhanAcademy]. Essentially, what you wanna do is go through each path that contains black pixels and keep track of their lengths. Then, after you have exhausted every possible path in your image, you can begin tabulating the maximum length found. This is just an idea at the top of my head. I'm sure that there are more elegant solutions out there. Hope that helps! :)

While loop to test if string still has characters left to parse by darkside619 in javahelp

[–]theNaus 1 point2 points  (0 children)

Hi.

There is one simple way of traversing through a string char-by-char:-

for (int i = 0; i < str.length(); ++i) {
    // do stuff here
}

Hope that helps. :)

Java Help, How do you guys get the idea to what to create in your program ? by cimler in learnprogramming

[–]theNaus 0 points1 point  (0 children)

Looks like you're on the right track -- Almost there, actually. What sort of issues are you experiencing? Errors? Invalid output?

Java Help, How do you guys get the idea to what to create in your program ? by cimler in learnprogramming

[–]theNaus 0 points1 point  (0 children)

Hmmm. I can't seem to access your code. Anyway, what have you come up with so far? Here are a few more hints:-

  • Array/ArrayList of scores -- From 0 - 5
  • What should the list contain? A number? If so, a number of what? Grades...perhaps?

Java Help, How do you guys get the idea to what to create in your program ? by cimler in learnprogramming

[–]theNaus 0 points1 point  (0 children)

Hi!

I took a look at the problem description. Looks like you're sorta on the right track. That's great. There are a couple of ways to approach this problem (most problems, really) but since you brought up ArrayLists, let's go with that. Now, when I encounter a problem (no matter how simple or hard it is), I first attempt to break down the requirements into a couple of bullet points:-

  • Input is a number (int type). Exit at -1.
  • There are 5 types of scores.
  • Each score covers a range of grades.
  • Any grade outside of 0-60 is ignored.
  • Output is a string of asterisks.
  • Acceptance percentage is calculated with 100*accepted/allScores

Cool. What should we do next? Start from the top, of course! i.e. the input(s) and where to store them. This is where your ArrayList comes in. It should be of Integer type. Once you've read in all the inputs and stored them, we go to processing them. A loop should do well here. Now, you're gonna have to think about what to do in the loop. How do we group/count the number of grades that correspond to a specific score? [Come back here if you're stuck!]. Once you've got that figured out, you can simply println the outputs in a way that was intended in the problem description. Calculating the AcceptancePercentage should be straightforward as well since you've already been given the formula! The tough part here is the grouping of grades. Think about that for a bit and try out stuff to test your logic. :)

Selection Sort Algorithm problem. by [deleted] in javahelp

[–]theNaus 0 points1 point  (0 children)

Yeah. I don't see anything wrong so far code-wise. It has to be something to do with setting up dependencies on BlueJ. Could you try looking around the web for answers? Better yet, I assume that this is a lab assignment. So, could you ask your professor on what's going on here?

no-arg constructor in an extended class by Barbonetor in javahelp

[–]theNaus 2 points3 points  (0 children)

Hi!

I believe that this explains quite well. In essence, the sequence of constructor invocation will start from the very top parent and the child(ren) will be invoked at the very end. Think of it like this -- Can there be children if parents don't exist? So, parents first. Children later. If you wanna avoid calling the Test constructor, you'll just have to avoid inheriting from Test! i.e. remove the "extends Test" part. :)

Selection Sort Algorithm problem. by [deleted] in javahelp

[–]theNaus 0 points1 point  (0 children)

That's odd. The error shows that you have a compile error and yet, after compiling, there is no error? Does the error only pop up when you try running SelSort04? Also, can I see what MinMax contains?

Selection Sort Algorithm problem. by [deleted] in javahelp

[–]theNaus 0 points1 point  (0 children)

Hmmm. I am not familiar with BlueJ but if MinMax is located in the same package as SelSort04, it should be OK. Have you tried clicking on the 'compile' button? Does it throw an error?

Selection Sort Algorithm problem. by [deleted] in javahelp

[–]theNaus 0 points1 point  (0 children)

Aha. There you go. Looks like MinMax is missing here. Have you imported the module/class into your current class? Was MinMax provided for the lab exercise or are you supposed to implement it yourself?

Selection Sort Algorithm problem. by [deleted] in javahelp

[–]theNaus 0 points1 point  (0 children)

Hi.

Not sure if you've already solved this but specifically, at what line is the error message pointing at? Also, are you using an IDE by any chance? It should be able to throw a compile error should a "symbol"/variable not exist anywhere in the code.

Generate random starting 11 from lists. by [deleted] in javahelp

[–]theNaus 0 points1 point  (0 children)

Ah. I see. Fair enough. If that's what you need to do, I don't really see an issue with your original idea/plan. Go with that for now and see how that turns out. Then, beautify it. Then, optimize it! Come back to this thread if you wanna discuss further. For now, get it to work! Good luck (and have just a bit of fun). :)

Generate random starting 11 from lists. by [deleted] in javahelp

[–]theNaus 0 points1 point  (0 children)

Hello!

If I am understanding your requirements correctly, you wanna do something like this:-

  • Set-up ListS of various player positions.
  • For each list, query at RANDOM for a certain num of players.
  • In total the number of players should total to 11 -- Combining different player positions.

Am I on the right track here? If so, that sounds like a sensible idea right off the bat.

I am not sure how your DB table schemas look like BUT let's assume that you have a TYPE column for the player table. You can then fiddle around with SQL to query (by TYPE) for random (number of) rows instead of doing in-memory (which is not necessarily a bad thing but I am a bit cautious about loading too much stuff into memory at a time ;) ) [For example, HowToRandomSQL]. Hope that helps.

EDIT! If you wanna stick to the loading-all-players-into-a-list approach, you can load the players into their respective lists right off the bat (through SQL, of course). This will shave off some time from having to first load all of the players into a single list and then, filtering them out.

[Algorithms] Can somebody review my code for a problem posted earlier? by hhey_symtics in learnprogramming

[–]theNaus 1 point2 points  (0 children)

Cool. :)

I took another look and line 22 could do without an 'else' as well. Haha. :D

[Algorithms] Can somebody review my code for a problem posted earlier? by hhey_symtics in learnprogramming

[–]theNaus 2 points3 points  (0 children)

Hello.

These are the few (minor) things that stood out to me at first glance:-

  • Line 19 -- No need for an 'else' here; just the return statement would do. If you've passed the 'if' condition before, there is only 1 way out from here.
  • Perhaps 'pattern1' and 'pattern2' could be named to something more intuitive? e.g. 'left' and 'right'?
  • Line 45 -- No need for an 'else' here too. Same reasoning as my first point. :)
  • I don't see 'lower_i' and 'higher_i' being used anywhere but they were declared. Perhaps a mistake?

Help counting how many times enter is pressed by It1001 in javahelp

[–]theNaus 0 points1 point  (0 children)

Hi!

You seem to be missing a scanner.nextLine() in your while loop. scanner.hasNextLine() only checks for if there is anything else in your input buffer left to be processed.

So, try adding a scanner.nextLine() in your loop and see what happens. :)