Program4.java - \/Mark Vainauskas this program utilizes the custom classes card and hand to\/create a poker hand to test the card and hand class

Program4.java - /Mark Vainauskas this program utilizes the...

This preview shows page 1 - 3 out of 8 pages.

//Mark Vainauskas, this program utilizes the custom classes: card and hand to//create a poker hand to test the card and hand class methods//Also used these 2 custom classes to create a Go Fish gameimport java.util.Random;import java.util.Scanner;public class Program4 {private static Scanner kb = new Scanner(System.in);public static void main(String[] args){char selected;boolean isRepeat = true;System.out.println("Welcome to the deck of cards program\n");do {displayMainMenu();do {selected = kb.next().charAt(0);switch (selected) {case '1':testDeckHand();break;case '2':goFish();break;case '3':isRepeat = false;break;default:System.out.println("That's not the number we are looking"+ " for.");System.out.println("Please try again. Enter number1, 2 or"+ " 3\n");System.out.println("Select one by inputing one of the"+ " numbers\n");}} while (selected != '1'&& selected != '2'&& selected != '3');} while (isRepeat);System.out.println("Program Terminated...");}private static void displayMainMenu() {System.out.println("\nSelect one of the options below\n");System.out.println("Enter 1: Test the DeckHand");System.out.println("Enter 2: Play \"Go Fish\"");System.out.println("Enter 3: Exit");}private static void displayHandMenu() {System.out.println("\nSelect one of the options below\n");System.out.println("Enter 0: Make an empty DeckHand");System.out.println("Enter 1: Add card to hand");System.out.println("Enter 2: Delete a specified card value from hand");System.out.println("Enter 3: Randomly delete any card from hand");System.out.println("Enter 4: Get amount of cards in hand");System.out.println("Enter 5: Get amount of cards of the same value"+ " in hand");System.out.println("Enter 6: Display all cards in hand");
Background image
System.out.println("Enter 7: Exit \"Test the DeckHand\"");}private static Hand whichHand(Hand poker, Hand empty){System.out.println("\nWhich hand would you like?\n");System.out.println("Enter 1: Poker hand (52 cards)");System.out.println("Enter 2: Your hand (0 cards)");char selected;do{selected = kb.next().charAt(0);switch (selected) {case '1':return poker;case '2':return empty;default:System.out.println("That's not the number we are looking"+ " for.");System.out.println("Please try again. Enter number 1 or 2\n");System.out.println("Select one by inputing one of the"+ " numbers\n");System.out.println("\nWhich hand would you like?\n");System.out.println("Enter 1: Poker hand (52 cards)");System.out.println("Enter 2: Empty hand (0 cards)");}} while (selected != '1'&& selected != '2');return null;}
Background image
Image of page 3

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture