Zavon Malone пре 6 година
родитељ
комит
ebb734942f

BIN
GuessingGame/GuessingGame.class Прегледај датотеку


+ 5
- 0
GuessingGame/GuessingGame.ctxt Прегледај датотеку

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

+ 42
- 0
GuessingGame/GuessingGame.java Прегледај датотеку

@@ -0,0 +1,42 @@
1
+
2
+/**
3
+ * Write a description of class GuessingGame here.
4
+ *
5
+ * @author (Zavon Malone)
6
+ * @version (10/21/18)
7
+ */
8
+import java.util.Scanner;
9
+import java.util.Random;
10
+public class GuessingGame
11
+{
12
+    public static void guess (String [] args){
13
+        Random randomNumber = new Random();
14
+        Scanner game = new Scanner(System.in);
15
+        int computerValue = randomNumber.nextInt(100);
16
+        int numberOfTries = 0;
17
+        int success = 0;
18
+        int guess = 0;
19
+
20
+        while(true){
21
+            computerValue = randomNumber.nextInt(100);
22
+            numberOfTries = 0;
23
+            while (true) {
24
+                System.out.println("Enter your best guess between 1 and 100");
25
+                guess =  game.nextInt();
26
+                numberOfTries++;
27
+
28
+                if (guess < 1 || guess > 100) System.out.println("Invalid input");
29
+                else if (guess == computerValue){
30
+                    System.out.println("YOU'RE RIGHT. Amount of attempts: " + numberOfTries + ", the number was" + computerValue);
31
+                    break;
32
+
33
+                }
34
+                else if (guess < computerValue) System.out.println("Your guess is to low!");
35
+                else if (guess > computerValue) System.out.println("Your guess is to high!");
36
+            }
37
+            System.out.println("Try Again? (1:Yes/2:No)");
38
+            if(game.nextInt() != 1) break;
39
+        }
40
+
41
+    }
42
+}

+ 12
- 0
GuessingGame/README.TXT Прегледај датотеку

@@ -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
GuessingGame/package.bluej Прегледај датотеку

@@ -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=25
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=64
13
+package.editor.y=149
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=70
32
+target1.y=10