-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial Commit #6
base: master
Are you sure you want to change the base?
Conversation
Assignment 4: Methods
|
||
//While loop: run this menu as long as the user does not enter 6 on the main menu | ||
while (input != 6) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't really effect the operation of the code, but you could have used a Do while loop here since the code should always run at least once. No need to pretest to loop. This works fine though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but you would be surprised how unusual do{}while()
loops are in the wild.
Really good documentation. I kinda forgot to add those comment blurbs before each function in mine...whoops! Also, I agree with gary. Adding the menu to a method is a smart idea! |
* score, percentage and letter grade | ||
* @param keyboard Scanner keyboard reads user input | ||
*/ | ||
public static void gradeCalc(Scanner keyboard) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fine method I like the reuses of Scanner. When we do objects this will be a pattern we will extract a lot. :)
The feedback I will give is that this single method is rather large, like its own program really. I know that is exactly what I asked you to do but we are going to introduce the way to resolve this issue tonight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@garyanewsome , @Hallbomb @DTkach thank you for your feedback! I left it out originally but then I thought it looked somewhat awkward left out like that while everything else had it's own method :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DTkach Thank you! I forget about the documentation sometimes, too. It isn't quite a habit for me yet. Usually I go back through after I'm finished coding everything and then add the comments but that can seem a bit tedious. I guess we'll just have to remember, when you start a method, close it and also add your comments right away!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ztmurphy21 Thank you for pointing that out. I fixed the slot machine game but it isn't up quite yet. I will upload it whenever I get home from work.
❤️ |
* slotValue() method assigns text value to each slot | ||
*/ | ||
for(int i = 0; i < randoms.length; i++) { | ||
randoms[i] = spin.nextInt(6); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pseudo random numbers are hard. .nextInt(6)
in this context might return the same number every time.
You have two choices:
- Create a new instance of Random for each loop `randoms[i] = (new Random()).nextInt(6);
- get a random window of the seedfile and you can skip the loop assignment for randoms
randoms = spin.ints(1,7).limit(3).toArray();
That second one is a little heavier. I think randoms are fun personally so maybe we will spend a little more time on it in class later this semester.
I agree with Gary as well, adding it to a method is a nice touch. |
changed to do-while loop as suggested by @Paa1006 , Also fixed the slot machine outcomes, so no more jackpots 100% of the time @ztmurphy21 @ninjapanzer
Assignment 4: Methods