Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /****************************************************************
- * Developer: Max Jensen
- *
- * Purpose of program: Slå en terning, som slår tal mellem 1-6,
- * hvis nr. 1 rammes, sluttes turen.
- *
- *****************************************************************/
- import java.util.*;
- public class Testing5_MaxJensen{
- public static void main(String[] args){
- System.out.println("Velkommen til terningspillet!\n");
- Scanner console = new Scanner(System.in);
- Random r = new Random(); // Benyttelsen af pseudorandom numre
- /**************************
- // Let's write some preconditions
- // To make sure we clearify it to be true.
- ***************************/
- response(console, "");
- public static int response(Scanner console, String prompt){
- int sum = 0; // make sure we enter the loop
- int roll1 = r.nextInt(6) + 1;;
- System.out.print(prompt); // enter a string please
- while(!prompt.equalsIgnoreCase("yes") && prompt.equalsIgnoreCase("no")) { // De Morgan Law ..
- while(!console.hasNext()){
- console.next();
- System.out.println("Not a string! - please try again with letters");
- System.out.print("Yes or no ? ");
- System.out.print(prompt);
- }
- } return console.next();
- }
- } // end of main
- } // end of class
Add Comment
Please, Sign In to add comment