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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
/** 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,
} catch (DealException de) {
System.out.println(de);
}