Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

sshurie
Copy link
Member

@sshurie sshurie commented Sep 21, 2015

Assignment 4: Methods

Assignment 4: Methods

//While loop: run this menu as long as the user does not enter 6 on the main menu
while (input != 6) {

Copy link

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.

Copy link
Member

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.

@DTkach
Copy link

DTkach commented Sep 23, 2015

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) {
Copy link
Member

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.

Copy link
Member Author

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 :)

Copy link
Member Author

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!

Copy link
Member Author

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.

@ninjapanzer
Copy link
Member

run:
SLOT MACHINE
    Place Your Bet (dollar amount [Integer]): 100

    [ Plums ] [ Plums ] [ Plums ]

    Congratulations! 3 Matching!
    You Won: $300
To play again, enter 4 on the menu
BUILD SUCCESSFUL (total time: 3 seconds)

❤️

* slotValue() method assigns text value to each slot
*/
for(int i = 0; i < randoms.length; i++) {
randoms[i] = spin.nextInt(6);
Copy link
Member

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:

  1. Create a new instance of Random for each loop `randoms[i] = (new Random()).nextInt(6);
  2. 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.

@Hallbomb
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants