aspose file tools*
The moose likes Beginning Java and the fly likes Java Project Beginner OOP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java Project Beginner OOP" Watch "Java Project Beginner OOP" New topic
Author

Java Project Beginner OOP

David Castle
Greenhorn

Joined: Dec 12, 2012
Posts: 3
Hello guys =D. I am pretty new to this forum. I have been taking some Java courses online and been doing fine, but recently we got this tough project I have been attempting to do. I have tried my best without help... but at last I must break and ask for help. There are two parts. The first was the create a "roulette type game" that would be the foundational reference for the second assignment. The first assignment is here. If you compile both you will easily see what it does but here are the guidelines: User guess's the number high or low. low is 1-18 high is 19-36. If they guess right they win. If the number randomizes to 0 they lose always.


I will post all the code under this portion. Anyways the second assignment goes like this. It seems to be a basic assignment taken from some book. I am given a Casino class I am NOT allowed to modify. Below directly here is the rules for this portion. This is the portion I am stuck on. I will add the codes below and label them. I tried posting on yahoo answers but they were rude saying "google it" as you know... it is kind of hard for new programmers to just "google" answers.

Create a class named Roulette with a method named betOnce that takes, as parameters, a
Scanner and the amount of the user bet.
 Generate a random number between 0 and 36 (that simulates the wheel)
 The user should be prompted to place their bet on 1) Low or 2) High or 3) a Number
 If the user selected 3) a Number, prompt the user to enter a guess between 1 and 36.
 If the user selected “1) Low”:
o And the number is between 1 & 18, the user wins and doubles their bet
o And the number is between 19 & 36, the user loses their bet
o And the number is 0, the user loses
 If the user selected “2) High”:
o And the number is between 1 & 18, the user loses their best
o And the number is between 19 & 36, the user wins and doubles their bet
o And the number is 0, the user loses
 If the user selected “3) a Number” and entered their guess:
o And the user guess matches the random number, they win 35 times their bet
o And the user guess does not match the random number, they lose their bet
o And the number is 0, the user loses
 Return the user’s winnings/losses from the betOnce method.





CLASS 1(driver class) first assignment



CLASS 2 (calculations here) first assignment






CASINO.JAVA (driver class) (cannot edit)



WHAT I GOT SO FAR (calculations here)
- I am stuck here because I was never taught how to hand off things other than ints and doubles to a 2nd class. I guess he assumed we would figure it out.... well I am trying based upon to errors I receive to change the syntax till it works... no avail. Also I am used to the efficient way to program would be to prompt the user for everything in the driver method then calculate in the 2nd method. It seems I need to promp the user for the bet type and number (if applicable) in the 2nd method??? I am not sure how to do this correctly. If only I could edit the main method I would have this done in a heartbeat!!!





I get many errors saying I wrong operand on the Outer IF statements in this....


This is my first time posting here. Sorry for broken english, VERY tired right now. been up a while trying to finish this. Help is MUCH appreciated. Most importantly, please explain your answer. It is not the answer I am most concerned with, but also the reasoning and knowledge behind it. By posting the first two classes you can see the extent of my knowledge.
Stuie Clarky
Ranch Hand

Joined: Nov 09, 2012
Posts: 76

Have you read up about how the Scanner class works? You are using the Scanner different in the second assignment to how you had it working in the first assignment. I'll come back to this once I have some coffee in me, but I think it would be a good place to start looking.


OCAJP 7
David Castle
Greenhorn

Joined: Dec 12, 2012
Posts: 3
Stuie Clarky wrote:Have you read up about how the Scanner class works? You are using the Scanner different in the second assignment to how you had it working in the first assignment. I'll come back to this once I have some coffee in me, but I think it would be a good place to start looking.


I have, but I am confused a bit. On the 2nd Method. I think I am using the scanner In correctly. The program will print YO when I run the Driver but It will not print HI. Also in the main Driver it will correctly print the Wallet after the 2nd method is called, but it does not print the correct result variable (because the result stays 0 since it is never correctly changed in the 2nd method. Again on the scanner. My knowledge is limited to importing it, using it to check for nextInt nextLine nextDouble ect. My professor jumped the gun a bit when heading straight into handing scanners off to other methods XD. In the earlier assignment the scanner only exists in the Driver and only to ask for a next int. In the second I am confused as to why it is being handed off to the 2nd method and since I am now allowed to edit the Driver this leads me to believe he wants me to prompt the user in the 2nd method... but how.... curiouser and curiousser!! thanks for the help btw. I got rasberry coffee brew here =D

David Castle
Greenhorn

Joined: Dec 12, 2012
Posts: 3
Ahhh I may have gotten it!!! I did it by ignoring that pesky Scanner from the Driver.... if you can think of the way to include that Scanner let me know, otherwise I just initialized an entirely new scanner.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Project Beginner OOP