Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package assignment.lab1;
- public class DGame {
- public static void main(String[] args) {
- Dicea playerone = new Dicea();
- playerone.flipone();
- System.out.println(playerone);
- }
- }
- ******************************************
- package assignment.lab1;
- import java.util.Random;
- public class Dicea {
- final int sumone = 75;
- int dice1, dice2, sum;
- Random rand = new Random();
- public Dicea() {
- flipone();
- }
- public void flipone() {
- dice1 = rand.nextInt(6) + 1;
- dice2 = rand.nextInt(6) + 2;
- sum = dice1 + dice2;
- System.out.println("Player one throwing the dice");
- System.out.println("Player one got: " + dice1 + " and " + dice2 + ", adding to sum " + sum);
- if (dice1 == dice2) {
- System.out.println("Matched! got to play again fella");
- flipone();
- }
- if (sum == sumone) {
- System.out.println("Player one wins!");
- }
- else {
- System.out.println("Player two turn!");
- playertwo();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement