Przeglądaj źródła

comleted TooLargeTooSmall

thulasi 6 lat temu
rodzic
commit
129e167531
5 zmienionych plików z 76 dodań i 1 usunięć
  1. BIN
      .DS_Store
  2. BIN
      Main.class
  3. 10
    0
      Main.ctxt
  4. 34
    1
      Main.java
  5. 32
    0
      package.bluej

BIN
.DS_Store Wyświetl plik


BIN
Main.class Wyświetl plik


+ 10
- 0
Main.ctxt Wyświetl plik

@@ -0,0 +1,10 @@
1
+#BlueJ class context
2
+comment0.target=Main
3
+comment0.text=\n\ Created\ by\ iyasuwatts\ on\ 10/17/17.\n
4
+comment1.params=args
5
+comment1.target=void\ main(java.lang.String[])
6
+comment2.params=
7
+comment2.target=int\ setGuessNumber()
8
+comment3.params=gameNumber\ guessNumber
9
+comment3.target=void\ compareNumbers(int,\ int)
10
+numComments=4

+ 34
- 1
Main.java Wyświetl plik

@@ -1,9 +1,42 @@
1
+import java.util.*;
1 2
 /**
2 3
  * Created by iyasuwatts on 10/17/17.
3 4
  */
4 5
 public class Main {
5
-
6
+    int guessNumber;
7
+    public static Scanner input;
8
+    
6 9
     public static void main(String[] args){
10
+   
11
+        System.out.println("!!!****Guessing Game****!!!");
12
+        int gameNumber = (int)Math.random() *10+1;
13
+       
14
+        input = new Scanner(System.in);
15
+        System.out.println("Guess a number between 10!");
7 16
         
17
+        compareNumbers(gameNumber,setGuessNumber());
18
+        
19
+    }
20
+   
21
+    
22
+    public static int setGuessNumber(){
23
+        
24
+        return input.nextInt();
25
+    }
26
+    
27
+    public static void compareNumbers(int gameNumber, int guessNumber){
28
+        
29
+        if(guessNumber == gameNumber)
30
+            System.out.println("Congrats! You won");
31
+            
32
+        else if(guessNumber < gameNumber){
33
+            System.out.println("Oops! That number is too small. Try Again!");
34
+            compareNumbers(gameNumber,setGuessNumber());
35
+        }
36
+            
37
+        else{
38
+            System.out.println("OOps! That number is too large. Try Again!");
39
+            compareNumbers(gameNumber,setGuessNumber());
40
+        }
8 41
     }
9 42
 }

+ 32
- 0
package.bluej Wyświetl plik

@@ -0,0 +1,32 @@
1
+#BlueJ package file
2
+editor.fx.0.height=722
3
+editor.fx.0.width=800
4
+editor.fx.0.x=240
5
+editor.fx.0.y=24
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=250
13
+package.editor.y=43
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=Main
28
+target1.showInterface=false
29
+target1.type=ClassTarget
30
+target1.width=80
31
+target1.x=140
32
+target1.y=30