Kaynağa Gözat

{JosonGuessingGame}

Jacqueline Joson 6 yıl önce
ebeveyn
işleme
737c57a6b4
6 değiştirilmiş dosya ile 93 ekleme ve 9 silme
  1. BIN
      GuessingGame.class
  2. 6
    0
      GuessingGame.ctxt
  3. 43
    0
      GuessingGame.java
  4. 0
    9
      Main.java
  5. 12
    0
      README.TXT
  6. 32
    0
      package.bluej

BIN
GuessingGame.class Dosyayı Görüntüle


+ 6
- 0
GuessingGame.ctxt Dosyayı Görüntüle

@@ -0,0 +1,6 @@
1
+#BlueJ class context
2
+comment0.target=GuessingGame
3
+comment0.text=\n\ Too\ Large\ Too\ Small\ Guessing\ Game.\n\n\ @jaejoson\n\ @10/18/2018\n
4
+comment1.params=args
5
+comment1.target=void\ main(java.lang.String[])
6
+numComments=2

+ 43
- 0
GuessingGame.java Dosyayı Görüntüle

@@ -0,0 +1,43 @@
1
+import java.util.*;
2
+import java.util.Random;
3
+/**
4
+ * Too Large Too Small Guessing Game.
5
+ *
6
+ * @jaejoson
7
+ * @10/18/2018
8
+ */
9
+public class GuessingGame {
10
+    
11
+    public static void main(String[] args) {
12
+           double rand = Math.random() * ((50 - 25) + 1) + 25;
13
+           double Val = Math.round(rand);
14
+           int numberOfTries = 0;
15
+           int previousGuess = 0; 
16
+           while (true) {
17
+            Scanner in = new Scanner(System.in);
18
+            System.out.print("Guess a number between 25 and 50. ");                                            
19
+            int userGuess = in.nextInt(); 
20
+            
21
+                
22
+                if (previousGuess != userGuess) {
23
+                    numberOfTries++;
24
+                    previousGuess = userGuess;
25
+                }
26
+                
27
+            if (userGuess != Val && userGuess > Val) { 
28
+                System.out.print("Number is waaaay too large! ");
29
+            } else if (userGuess != Val && userGuess < Val) {
30
+                System.out.print("Number is too small :( ");
31
+            } else { 
32
+                System.out.print("You got the correct guess! ");
33
+                System.out.print("It took you " + numberOfTries + " tries.");
34
+                break;
35
+            }
36
+            
37
+        }
38
+    
39
+      
40
+    
41
+    
42
+    }
43
+}

+ 0
- 9
Main.java Dosyayı Görüntüle

@@ -1,9 +0,0 @@
1
-/**
2
- * Created by iyasuwatts on 10/17/17.
3
- */
4
-public class Main {
5
-
6
-    public static void main(String[] args){
7
-        
8
-    }
9
-}

+ 12
- 0
README.TXT Dosyayı Görüntüle

@@ -0,0 +1,12 @@
1
+------------------------------------------------------------------------
2
+This is the project README file. Here, you should describe your project.
3
+Tell the reader (someone who does not know anything about this project)
4
+all he/she needs to know. The comments should usually include at least:
5
+------------------------------------------------------------------------
6
+
7
+PROJECT TITLE:
8
+PURPOSE OF PROJECT:
9
+VERSION or DATE:
10
+HOW TO START THIS PROJECT:
11
+AUTHORS:
12
+USER INSTRUCTIONS:

+ 32
- 0
package.bluej Dosyayı Görüntüle

@@ -0,0 +1,32 @@
1
+#BlueJ package file
2
+editor.fx.0.height=716
3
+editor.fx.0.width=1280
4
+editor.fx.0.x=0
5
+editor.fx.0.y=23
6
+objectbench.height=101
7
+objectbench.width=776
8
+package.divider.horizontal=0.6
9
+package.divider.vertical=0.8007380073800738
10
+package.editor.height=427
11
+package.editor.width=674
12
+package.editor.x=101
13
+package.editor.y=62
14
+package.frame.height=600
15
+package.frame.width=800
16
+package.numDependencies=0
17
+package.numTargets=1
18
+package.showExtends=true
19
+package.showUses=true
20
+project.charset=UTF-8
21
+readme.height=58
22
+readme.name=@README
23
+readme.width=47
24
+readme.x=10
25
+readme.y=10
26
+target1.height=50
27
+target1.name=GuessingGame
28
+target1.showInterface=false
29
+target1.type=ClassTarget
30
+target1.width=120
31
+target1.x=110
32
+target1.y=60