/* Author: Gary Zoppetti and Stephanie Elzer * Date: March 9th, 2007 * Purpose: To test the functionality of the Card class */ import java.util.Scanner; public class CardDriver { public static void main(String args[]) { Card card1 = new Card(); Card card2 = new Card(Card.Suit.Hearts, 'K'); System.out.println(card1); System.out.println(card2); // Choose a card randomly and display the card card1.choose(); System.out.println(card1); // Ask user to choose a card Scanner in = new Scanner(System.in); String usersuit; // Read in user's suit as a string System.out.print("Enter the suit (Hearts, Diamonds, Spades, Clubs): "); usersuit = in.next(); // convert to all lowercase usersuit = usersuit.toLowerCase(); // based on string value, set suit of the card if (usersuit.equals("hearts")) card1.setSuit(Card.Suit.Hearts); else if (usersuit.equals("clubs")) card1.setSuit(Card.Suit.Clubs); else if (usersuit.equals("spades")) card1.setSuit(Card.Suit.Spades); else card1.setSuit(Card.Suit.Diamonds); // Read in face value as a string System.out.print("Enter the face value (2,3,4,5,6,7,8,9,T,J,Q,K, or A):"); String facestr = in.next(); // need just a character for face, so take first character of user input char userface = facestr.charAt(0); card1.setFace(userface); System.out.println("You selected: " + card1); } }