Link to home
Start Free TrialLog in
Avatar of Ikram_Bohra
Ikram_Bohra

asked on

Contract Bridge In Java

Hi

I'm currently programming the card game contract bridge using java.  I need a little help in checking whether the card exists in the deal.  

I have created a RandomDeal class, where the cards are defined, a TestDeal class, where a deal is distributed and a BridgeApp class, where the methods are called and run.  

Currently this is what I have got in the standard play method:
  /**                      Request input for card
            Check whether card exists
            If not, output error message
            If it does, play card **/
            
            System.out.println("SOUTH PLAY A CARD:");
            card = keyboardInput.readLine();
            
            switch (checkCard) {
                        
                        
            default:
            System.out.println("\n Error: YOU DO NOT HAVE THAT CARD " +
                                    card + "\n");
            }
      
            System.out.println("NORTH PLAY A CARD:");
            card = keyboardInput.readLine();

I know this is incomplete, but I cant seem to get my head round, how to check the RandomDeal class for validity.  

 
SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mike_mian
mike_mian

coe would look something like this:

/**                     Request input for card
          Check whether card exists
          If not, output error message
          If it does, play card **/
         
          System.out.println("SOUTH PLAY A CARD:");
          card = keyboardInput.readLine();
         try {
            RandomDeal.checkCard(card, 'S');
        } catch (DealException de) {
           System.out.println(de);
        }