Computers and Technology, 23.01.2022 04:00 hollandhogenson
Project is due tonight - Please help!
I need to create a game in Java that involves the card game 21, and here is the files:
Main. java
import java. util.*; //for the Scanner class methods
class Main {
public static void main(String[] args){
Scanner input = new Scanner(System. in);
//declare 3 cards for you and 3 cards for the computer; call the dealCard method to generate a unique card as shown.
Card myC1 = dealCard();
Card myC2 = dealCard();
Card myC3 = dealCard();
Card botC1 = dealCard();
Card botC2 = dealCard();
Card botC3 = dealCard();
//print your 2 Cards & total
System. out. println(myC1);
System. out. println(myC2);
System. out. println("Your cards: " + myC1 + ", " + myC2);
//if you have 21, you win, game ends.
if((myC1 + myC2) == 21){
System. out. println("You have won the game!");
}
//print the computers first card
System. out. println(botC1);
System. out. println(botC2);
System. out. println("Bot's cards: " + botC1 + ", " + botC2);
//ask if user wants another card & print out those 3 cards & total if so
String promptCont = input. nextLine();
System. out. println("Would you like to add another card?");
if (promptCont == "y"){
System. out. println(myC1);
System. out. println(myC2);
System. out. println(myC3);
}
//give computer another card if computer total < 17
if((botC1 + botC2) < 17){
System. out. println(botC1);
System. out. println(botC2);
System. out. println(botC3);
}
//print out computer's cards & totals
System. out. println(botC1 + botC2 + botC3);
//determine and print the winner
if((botC1 + botC2 + botC3) == 21){
System. out. println("Bot wins!");
}
else if((botC1 + botC2 + botC3) + (myC1 + myC2 + myC3) != 21){
System. out. println("nobody won :(");
} else if((myC1 + myC2 + myC3) == 21){
System. out. println("You win!");
}
}//end of main method
//don't change this method
public static Card dealCard(){
Card temp = new Card();
String[] names = {"Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King", "Ace"};
int num = (int)(Math. random()*52);
while(Card. getDeck()[num]==true)
num = (int)(Math. random()*52 );
switch(num/13){
case 0: temp = new Card(names[num%13], "Clubs", num+2 ); break;
case 1: temp = new Card(names[num%13], "Diamonds", num+2-13); break;
case 2: temp = new Card(names[num%13], "Hearts", num+2-26); break;
case 3: temp = new Card(names[num%13], "Spades", num+2-39); break;
}
if(temp. getPointValue()==11 || temp. getPointValue()==12 || temp. getPointValue()==13)
temp. setPointValue(10); //in 21, face cards = 10
if(temp. getPointValue()==14)
temp. setPointValue(11); //in 21, aces = 11
Card. addToDeck(temp);
return temp;
} //end of dealCard method
} //end of Main. java class
Card. java
//Card class goes here.
public class Card{
private String rank;
private String suit;
private int PointValue;
private static boolean[] deck = new boolean[52]; //instance field
public void initDeck()
{
this. rank = "None";
this. suit = "None";
this. PointValue = 0;
}
public void Cards(String rank, String suit, int PointValue)
{
this. rank = rank;
this. suit = suit;
this. PointValue = PointValue;
}
//these methods are part of the Card class.
public static boolean[] getDeck(){
return deck;
}
public static int[] getPointValue(){
PointValue = this. PointValue;
return PointValue;
}
public static void setPointValue(int newVal){
}
public static void addToDeck(Card c1)
{
if(c1.suit. equals("Clubs"))
deck[c1.pointValue - 2] = true;
else if (c1.suit. equals("Diamonds"))
deck[c1.pointValue - 2 + 13] = true;
else if (c1.suit. equals("Hearts"))
deck[c1.pointValue - 2 + 26] = true;
else
deck[c1.pointValue - 2 + 39] = true;
}
}
The rubric is attached. Thanks yall :)
Answers: 1
Computers and Technology, 22.06.2019 17:40
Consider the simple 3-station assembly line illustrated below, where the 2 machines at station 1 are parallel, i.e., the product only needs to go through one of the 2 machines before proceeding to station 2.what is the throughput time of this process?
Answers: 2
Computers and Technology, 22.06.2019 19:20
How might the success of your campaign be affected if you havenβt carefully completed all field data or if you accidentally insert the wrong merge field in the document?
Answers: 2
Computers and Technology, 23.06.2019 16:30
20 points archie wants to use a reflector as he photographs a newlywed couple. what would he consider in his choice? a. shadow and sunny b. homemade and professional c. lamps and boards d. incident and reflected e. neutral density and enhancement
Answers: 3
Computers and Technology, 23.06.2019 17:00
1. which of the following is not an example of an objective question? a. multiple choice. b. essay. c. true/false. d. matching 2. why is it important to recognize the key word in the essay question? a. it will provide the answer to the essay. b. it will show you a friend's answer. c. it will provide you time to look for the answer. d. it will guide you on which kind of answer is required.
Answers: 1
Project is due tonight - Please help!
I need to create a game in Java that involves the card game...
Mathematics, 06.10.2019 22:30
History, 06.10.2019 22:30
History, 06.10.2019 22:30
Computers and Technology, 06.10.2019 22:30
Mathematics, 06.10.2019 22:30
English, 06.10.2019 22:30
English, 06.10.2019 22:30
History, 06.10.2019 22:30
Computers and Technology, 06.10.2019 22:30
Geography, 06.10.2019 22:30