Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Card
- {
- private String suit;
- private int Value;
- public Card(String suit, int Value)
- {
- this.suit = suit;
- this.Value = Value;
- if(!suit.equals("SPADE") && !suit.equals("HEART") && !suit.equals("CLUB") && !suit.equals("DIAMOND"))
- {
- System.out.println("That's not a usuable suit");
- }
- if(Value < 1 || Value > 14)
- {
- System.out.println("That's not usuable value");
- }
- }
- public String getSuit(String suit)
- {
- return suit;
- }
- public int getValue(int Value)
- {
- return Value;
- }
- public String toString(String suit, int Value)
- {
- if(Value == 11)
- {
- return "Suit:" + suit + "Value: Jack";
- }
- if(Value == 12)
- {
- return "Suit:" + suit + "Value: Queen";
- }
- if(Value == 13)
- {
- return "Suit:" + suit + "Value: King";
- }
- if(Value > 0 && Value < 11)
- {
- return "Suit:" + suit + " Value" + Value;
- }
- return null;
- }
- }
- public class Deck
- {
- private int count = 1;
- public Deck()
- {
- Card[] deck = new Card[52];
- int[] Values = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
- String[] Suites = {"Spade", "Heart", "Clubs", "Diamond"};
- for(int V = 0; V < 12; V++)
- {
- for(int S = 0; S < 4; S++)
- {
- for(int i = 0; i < 52; i++)
- {
- Card card = new Card(Suites[S], Values[V]);
- deck[i] = card;
- if(count != 4)
- {
- V--;
- count++;
- }
- if(count == 4)
- {
- count = 0;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment