daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest Oct 12th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package assignment.lab1;
  2.  
  3. public class DGame {
  4.     public static void main(String[] args) {
  5.         Dicea playerone = new Dicea();
  6.         playerone.flipone();
  7.         System.out.println(playerone);
  8.     }
  9. }
  10.  
  11. ******************************************
  12.  
  13. package assignment.lab1;
  14. import java.util.Random;
  15.  
  16. public class Dicea {
  17.     final int sumone = 75;
  18.     int dice1, dice2, sum;
  19.     Random rand = new Random();
  20.     public Dicea() {
  21.         flipone();
  22.     }
  23.     public void flipone() {
  24.         dice1 = rand.nextInt(6) + 1;
  25.         dice2 = rand.nextInt(6) + 2;
  26.         sum = dice1 + dice2;      
  27.         System.out.println("Player one throwing the dice");
  28.         System.out.println("Player one got: " + dice1 + " and " + dice2 + ", adding to sum " + sum);
  29.         if (dice1 == dice2) {
  30.             System.out.println("Matched! got to play again fella");
  31.             flipone();
  32.         }
  33.         if (sum == sumone) {
  34.             System.out.println("Player one wins!");
  35.         }
  36.         else {
  37.             System.out.println("Player two turn!");
  38.             playertwo();
  39.         }
  40.     }
  41. }
RAW Paste Data
Top