Design the storyboard, interactivity diagram, object dictionary, and any necessa
ID: 3532016 • Letter: D
Question
Design the storyboard, interactivity diagram, object dictionary, and any necessary scripts for an interactive program that allows a user to play a card game named Lucky Seven. In real life, the game can be played with seven cards, each containing a number from 1 through 7, that are shuffled and dealt number side down. To start the game, a player turns over any card. The exposed number on the card determines the position (reading from left to right ) of the next card that must be turned over. For example, if the player turned over the fist card and its number is 7, the next card turned over must be the seventh card (counting from left to right). If the player turns over a card whose number denotes a position that was already turned, the player loses the game. If the player succeeds in turning over all seven cards, the player wins.
Explanation / Answer
import java.lang.Math;
import java.io.*;
public class games {
public void rules() {
System.out.print("Here's the rules. You and another dude roll 2 six-sided dice");
System.out.print(" each and then you total them up based on the scoring system.");
System.out.print(" a basic number, like 5, is worth less than a higher basic number");
System.out.print(", like 11 and a double like double ones, is better than the highest");
System.out.println(" number, and a 7 beats all. Got that? Now to quit...");
}
public boolean play() {
System.out.println("Rolling dice...");
double p1r,p2r,d1r,d2r;
p1r = Math.random();
p2r = Math.random();
d1r = Math.random();
d2r = Math.random();
p1r *= 6;
p2r *= 6;
d1r *= 6;
d2r *= 6;
int p1,p2,d1,d2;
p1 = (int) p1r;
p2 = (int) p2r;
d1 = (int) d1r;
d2 = (int) d2r;
p1++;
p2++;
d1++;
d2++;
int pscore = 0;
int dscore =0;
String ptype;
if(p1 == p2){
ptype = "pair";
pscore = 8 + p1;
}
else if((p1+p2) == 7){
ptype="seven";
pscore=15;
}
else {
ptype = "single";
if((p1 + p2) < 7){
pscore = (p1 + p2) - 2;
}
else if ((p1 + p2) > 7){
pscore = (p1 +p2) - 3;
}
}//else ends
//Calculating dealer's score
String dtype;
if(d1 == d2){
dtype = "pair";
dscore = 8 + d1;
}
else if((d1 + d2) == 7){
dtype = "seven";
dscore = 15;
}
else {
dtype = "single";
if((d1 + d2) < 7){
dscore = (d1 + d2) - 2;
}
else if ((d1 + d2) > 7){
dscore = (d1 +d2) - 3;
}
else {
dscore = 0;
}
}//else ends
//calculating winner
String winner;
if(pscore < dscore){
winner="d";
}
else if(pscore == dscore){
winner="t";
}
else{
winner="p";
}
//Displaying scores
//Display Player before scores
System.out.print("Player: ");
if(ptype == "single"){
System.out.println(p1+" + "+p2+" = "+(p1 + p2));
}
else if(ptype == "pair"){
System.out.println("A pair of "+p1+"'s!");
}
else if(ptype == "seven"){
System.out.println("Seven!!");
}
//Display Dealer: before scores
System.out.print("Dealer: ");
if(dtype == "single"){
System.out.println(d1+" + "+d2+" = "+(d1 + d2));
}
else if(dtype == "pair"){
System.out.println("A pair of "+d1+"'s!");
}
else if(dtype == "seven"){
System.out.println("Seven!!");
}
//Say who wins
if(pscore > dscore){
System.out.println("You Win!");
}
else if(pscore < dscore){
System.out.println("You lose. Too bad");
}
else if(pscore == dscore){
System.out.println("You tied.");
}
//Display credits
System.out.println("");
System.out.println("");
return true;
}//Method ends
}//class ends
//this is the lucky7 file which u need to run
import java.lang.Math;
import java.io.*;
public class lucky7 {
public static void main(String args[]) {
games thisGame = new games();
if(args.length == 1){
if(args[0] == "rules"){
thisGame.rules();
}
}
thisGame.play();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.