#38 Too Large Too Small Lab

Açık
jasamuels master içindeki jasamuels/ZCW-TooLargeTooSmall-BlueJ:master işlemelerini 1 ile birleştirmek istiyor
5 değiştirilmiş dosya ile 82 ekleme ve 9 silme
  1. 0
    9
      Main.java
  2. BIN
      console.class
  3. 5
    0
      console.ctxt
  4. 45
    0
      console.java
  5. 32
    0
      package.bluej

+ 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
-}

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


+ 5
- 0
console.ctxt Dosyayı Görüntüle

@@ -0,0 +1,5 @@
1
+#BlueJ class context
2
+comment0.target=console
3
+comment1.params=args
4
+comment1.target=void\ main(java.lang.String[])
5
+numComments=2

+ 45
- 0
console.java Dosyayı Görüntüle

@@ -0,0 +1,45 @@
1
+import java.util.*;
2
+public class console
3
+{
4
+    public static void main(String[] args){
5
+        
6
+    //Get random # and start counter of guesses
7
+    int counter = 0;
8
+    int max = 10;
9
+    int min = 1;
10
+    int range = max - min + 1;
11
+    int number = 0;
12
+    int guess = 0;
13
+    
14
+        for (int i = 0; i < 10; i++) { 
15
+            number = (int)(Math.random() * range) + min; }
16
+
17
+    Scanner in = new Scanner(System.in);
18
+    System.out.print("Take a guess between 1-10");
19
+    
20
+    while (in.hasNextInt() == true) {
21
+    
22
+    counter++;
23
+
24
+    guess = in.nextInt();
25
+    
26
+    if (guess == number) {
27
+        System.out.print("Correct Guess!");
28
+    }
29
+    else if (guess < number && guess <= 10 && guess != 0){
30
+        System.out.print("Too Small. Try Again!");
31
+    } else if (guess > number && guess <= 10){
32
+        System.out.print("Too Large. Try Again!");
33
+    } else {
34
+        System.out.print("Oops! Please enter a number between 1 and 10");
35
+    }; };
36
+    if (in.hasNextInt() == false && guess != number) {
37
+        int guesses = range - counter;
38
+        System.out.print("Thanks for playing! You were " + guesses + " away from guessing the correct answer! Otherwise it would have taken at least 10 tries.");
39
+        in.close();
40
+    } else {
41
+        System.out.print("Thanks for playing and congrats on guessing correct!");
42
+        in.close();
43
+    };};
44
+
45
+  }

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

@@ -0,0 +1,32 @@
1
+#BlueJ package file
2
+editor.fx.0.height=709
3
+editor.fx.0.width=800
4
+editor.fx.0.x=262
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=65
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=console
28
+target1.showInterface=false
29
+target1.type=ClassTarget
30
+target1.width=80
31
+target1.x=70
32
+target1.y=10