Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Card {
- String suit;
- int value;
- public Card() {
- suit = "Spades";
- value = 1;
- }
- public Card(String a, int b) {
- suit = a;
- value = b;
- }
- public int getValue() {
- return value;
- }
- public void printCard() {
- //Map<Integer, String> ranks = new HashMap<>;
- System.out.println(value + " of " + suit);
- }
- }
- import java.util.*;
- public class Deck {
- ArrayList<Card> c = new ArrayList<Card>();
- String suits[] = {"Spades", "Hearts", "Clubs", "Diamonds"};
- Random r = new Random();
- public Deck(int amount) {
- for(int i = 0; i < amount; i++) {
- c.add(new Card(suits[r.nextInt(4)], r.nextInt(14)));
- }
- }
- public void printDeck() {
- for(int i = 0; i < c.size(); i++) {
- c.get(i).printCard();
- }
- }
- }
- public class Main {
- public static void main(String args[]) {
- Deck deck = new Deck(5);
- deck.printDeck();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement