I am suppose to make a Driver called Black Jack and a Class program called Card. I have not made the Driver class yet because the professor asked us to do the class program Card first. This is what the teacher has said to use:
Above is the file describing what I am to use. ABSOLUTELY USE NO ARRAYS OR ARRAY LIST , we have not learned that yet and are only allowed to use things we have learned. I have asked a lot of people for help and they always say use arrays and dont understand why I cant use them.
My code so far... Sorry the tabs and spacings are not right I usually figure those out later on.
import java.util.Scanner;
public class Card
{
private final int MAX = 13;
private int face, suit, points, Spades, Clubs, Diamonds, Hearts, Ace, Jack, Queen, King;
prive int randomNumber = new newCard();
//CONSTRUCTORS
public Card() {
randomNumber = newCard()
}
public Card(int faceValue,int suitValue) {
//face
Ace = 1;
Jack = 11;
Queen = 12;
King = 13;
//suit
Hearts = 1;
Diamonds = 2;
Clubs = 3;
Spades = 4;
}
//^^^^^^^
//Mutators
public void setFace(int face)
{
face = face
}
public void setSuit(int suit)
{
suit = suit
}
//Accessors
public int getFace()
{
return face;}
public int getSuit()
{
return suit;}
public int getPoints()
{
return points;}
//^^^^^^^^^^^^^^^^^
public String toString()
{
return "Players cards are " + " ";
}
}
My problem Is i have no idea what needs to be done with the mutators I have been putting face = face but its not working out, Also how am i suppose to output the toString method Because im not quiet understanding how the whole face and suit thing is suppose to work the suits is like hearts = 1 and faces are like Jacks =11 I am thinking my program would get confused and output the wrong ones.
First try this.face = face that should do the assignment in setFace. Same for suit. Your default constructor needs to use the java.util.Random class to generate your card values. getPoints should calculate a cards value based on the file you have been given ie if face card = 10 etc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.