From 717a1964133f05eb9d39e879f2ed27ebb054cdb2 Mon Sep 17 00:00:00 2001 From: mo Date: Tue, 18 Jun 2019 16:00:24 -0600 Subject: add Q4 assignment --- src/Q4/README.md | 26 ++++++++++++++++++++++++++ src/Q4/RandomSumGame.java | 14 ++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/Q4/RandomSumGame.java (limited to 'src/Q4') diff --git a/src/Q4/README.md b/src/Q4/README.md index fd3c91d..355bc0d 100644 --- a/src/Q4/README.md +++ b/src/Q4/README.md @@ -6,6 +6,32 @@ Student ID: 3431709 1. Problem Statement: ```text +Craps is a dice game where two dice are rolled. +Each die has six faces representing values 1, 2, 3, 4, 5, or 6. + +1. If the sum is 2, 3, or 12 (called craps), you lose; +2. If the sum is 7 or 11 (called natural), you win; +3. If the sum is any other value (4, 5, 6, 8, 9, or 10), a value point is established, and you continue to roll until you either roll a sum of the value point or a 7. +If the sum of the new roll is equal to the value point, then you win; if the sum of the new roll is equal to 7, then you lose. +Remember, in option (III), you continue to roll until you get a 7 or the value point. + +Sample runs: +* You rolled 5 + 6 = 11; you win +* You rolled 1 + 2 = 3; you lose +* You rolled 2 + 2 = 4; you establish the value point 4; + – Roll again 2 + 3 = 5; roll + – Roll again 2 + 1 = 3; roll + – Roll again 2 + 2 = 4; you win +* You rolled 2 + 6 = 8; you establish the value point 8; + – Roll again 4 + 4 = 8; you win +* You rolled 3 + 2 = 5; you establish the value point 5; + – Roll again 1 + 1 = 2; roll + – Roll again 2 + 2 = 4; roll +* Roll again 1 + 1 = 2; roll +* Roll again 3 + 4 = 7; you lose + +Develop a program that plays craps with a player three times. +At the end, the program prints the number of times the player won and the number of times the player lost. ``` 2. Description of the Code: diff --git a/src/Q4/RandomSumGame.java b/src/Q4/RandomSumGame.java new file mode 100644 index 0000000..823c32e --- /dev/null +++ b/src/Q4/RandomSumGame.java @@ -0,0 +1,14 @@ +package Q4; + +public class RandomSumGame { + private boolean start; + private int d1; + private int d2; + private int sum; + private int valuePoint; + private String status; + + public void play(int d1, int d2) { } + public void play() { } + public void rollDice() {} +} -- cgit v1.2.3