subject

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 :)

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 21:00
Kirk found a local community college with a two-year program and he is comparing the cost with that of an out-of-state two-year school. what is the expected total cost for one year at the local community college if kirk lives at home? what is the expected total cost for one year at the out-of-state school if kirk lives on campus?
Answers: 2
question
Computers and Technology, 22.06.2019 22:00
Consider the following declarations (1, 2, 3, 5, 7)class bagtype{public: void set(string, double, double, double, double); void print() const; string getstyle() const; double getprice() const; void get(double, double, double, double); bagtype(); bagtype(string, double, double, double, double); private: string style: double l; double w; double h; double price; }; a.) write the definition of the number function set so that private members are set according to the parametersb.) write the definition of the member function print that prints the values of the data membersc.) write the definition of the default constructor of the class bagtype so that the private member variables are initialized to "", 0.0, 0.0, 0.0, 0.0, respectively d.) write a c++ statement that prints the value of the object newbag.e.) write a c++ statement that declares the object tempbag of type bagtype, and initialize the member variables of tempbag to "backpack", 15, 8, 20 and 49.99, respectively
Answers: 3
question
Computers and Technology, 23.06.2019 03:00
State 7 common key's for every keyboard
Answers: 1
question
Computers and Technology, 23.06.2019 09:00
Before you record your own voice, you should a. record other people's voices b. warm up and practice difficult names c. listen to your favorite songs d. read a transcript of a good radio news segment
Answers: 1
You know the right answer?
Project is due tonight - Please help! I need to create a game in Java that involves the card game...
Questions
question
Mathematics, 04.01.2021 02:10
question
Mathematics, 04.01.2021 02:10
Questions on the website: 13722367