Ive began to write a Write a program which will represents a standard playing card.
Every card has a value and a suit.
Every Playing Card Has a Value And A Suit
Values are either in the range 2 to 10 or one of the face cards Ace, King, Queen and Jack.
The standard suits are Clubs, Diamonds, Hearts and Spades.
The PlayingCard class must have the following public methods
Now i need to set the values of the faces:
The way i have done this is use the final method:
This is my code for the PlayingCard.java
Now i need another class called PlayingCardTester.java.
I have created this but it has no content so far.
When i call the to String method it should bring up the results like this:
PlayingCard[value=King, suit=Hearts]
The part that i am on is the equals method:
Im not sure on what information do i put here.
Then the Constructor its self
How do i change the int value to its card representative.
Thanks
##ADMIN - - Could You Delete This Thread Please I Clicked Post And Went Back By Mistake And I Have 2 Threads on Same Subject
Thanks
Every card has a value and a suit.
Every Playing Card Has a Value And A Suit
Values are either in the range 2 to 10 or one of the face cards Ace, King, Queen and Jack.
The standard suits are Clubs, Diamonds, Hearts and Spades.
The PlayingCard class must have the following public methods
Now i need to set the values of the faces:
- Jack has the value eleven
- Queen has the value twelve
- King has the value thirteen
- Ace has the value fourteen
The way i have done this is use the final method:
This is my code for the PlayingCard.java
/*
Program Title: PlayingCard
Author: applemad20
Created: 02 December 2012
Version: 1.0
*/
/**
* DESCRIPTION OF CLASS HERE()
*
* @author GethynJones
* @version 1.0
*/
public class PlayingCard
{
private int value;
private int suit;
public final int JACK = 11;
public final int QUEEN = 12;
public final int KING = 13;
public final int ACE = 14;
/**
* Gets The Current Card Value
*
* @return The Current Card
*/
public int getValue()
{
return value;
}
/**
* Gets The Current Value Of The Suit
*
* @return The Current Suit
*/
public int getSuit()
{
return suit;
}
/**
* Returns The toString Representation Of The Class Data
* @return String For Printing
*/
@Override
public String toString()
{
return "PlayingCard [ value = " + getValue() + " suit = " + getSuit() + "]";
}
/**
* Returns The string Format On How The Data WIll Be Printed On Console
* @return String.format
*/
public String format()
{
return String.format("%-30s %8.2f", "Gethyn", 2.33);
}
/**
* Tests Whether This Card Is Equal To Some Other Card
* @param card The Card To Be Tested
*
* @return returns true If The Suit And Value Of The Test Card Is
* Equal To The Suit And Value Of This Card Otherwise false If returned
*/
// public boolean equals(PlayingCard card)
// {
//
// }
//
public PlayingCard(int value, int suit)
{
this.value = value;
this.suit = suit;
}
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
// TODO code application logic here
}
}
Now i need another class called PlayingCardTester.java.
I have created this but it has no content so far.
When i call the to String method it should bring up the results like this:
PlayingCard[value=King, suit=Hearts]
The part that i am on is the equals method:
/**
Tests whether this card is equal to some other card
@param card the card to be tested
@return returns true if the suit and value of the test card is equal to the suit and value of this card otherwise false is returned
*/
public boolean equals(PlayingCard card)
{ ... }
Im not sure on what information do i put here.
Then the Constructor its self
public PlayingCard(int value, int suit)
{
this.value = value;
this.suit = suit;
}
How do i change the int value to its card representative.
Thanks
##ADMIN - - Could You Delete This Thread Please I Clicked Post And Went Back By Mistake And I Have 2 Threads on Same Subject
Thanks