Learn to work through higher level application design with this unique tutorial. I know I move kind of fast, but hopefully you have followed along with my other videos and are sharp on all of the code I implement here. Good Luck! :)
code:
import java.util.Scanner;
class SimpleGame {
public static void main(String args[]) {
Actor myActor = new Actor();
System.out.println("Guessing Game 5000");
System.out.println("------------------");
while(true) {
myActor.MakeNumber();
myActor.GetInput();
myActor.CheckResponse();
}
}
}
class Actor {
int x, Response, score;
void MakeNumber() {
x = (int)(Math.random()*11);
while (x == 0) {
x = (int)(Math.random()*11);
}
}
void GetInput() {
Scanner myScanner = new Scanner(System.in);
System.out.println("");
System.out.println("Please enter your guess");
Response = myScanner.nextInt();
}
void CheckResponse() {
if (Response == x) {
score++;
System.out.println("That's Right");
System.out.println("Score: " + score);
System.out.println("");
}
else {
System.out.println("That's Wrong");
System.out.println("The number was: " + x);
System.out.println("Score: " + score);
}
}
}
Please check out my other vids for more tutorials. Also, please leave comments with any suggestions.
Subscribe, comment, rate.
sure.... i'll sub... thanks :)
allendupras 2 weeks ago
Thank you for your tutorials.
AngusT07171 8 months ago
Nice one,Subscribed.
Arjun007ize 10 months ago