Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me write the code to test threeofakind method. I included the code I wrote for the method in the programmer defined class. Please

Please help me write the code to test threeofakind method. I included the code I wrote for the method in the programmer defined class. Please make a simple solution.

image text in transcribed
String suit = card1.getSuit(); // Get the suit of the first In the Lab 7App class testThreeOfAKind method: // Check if all cards have the same suit as the first card 29. Go to the testThreeOfAKind method. Declare and instantiate a PokerHand object using the if (card2.getSuit() . equals (suit) && card3.getSuit().equals( parameterized constructor. Pass in the following four Card references: twoClubs, return true; // Return true if all cards have the same 8982889286 } else { threeClubs, fourClubs, fiveClubs. tem Library [Java return false; // Return false if any card has a differe 30. In the testThreeOfAKind method, write an output statement to display "Testing threeofAKind method: " to the console. See the expected output below. 31. There are five combinations you will need to thoroughly test the threeOfAKind method. b6App.java 690 1** oneBookEntry.jav Write code to test the one combination that will return false and each combination that will 70 * threeOfAKind method -- return true. Replace cards in the hand to put the desired cards in specific positions. See the 71 * determines the different ways that three of a kind may exist wit tem Library [Java 72 * assumes that four of a kind has already been tested output below to change the hand as required to test each scenario. 73 * @return true if three of a kind exists, false otherwise 32. Each time you test it, display "Three of a kind" if the method returns true and "Not three of a 74 kind" if it returns false. 75 1 /#27 ard.java 76 public boolean threeOfAKind() { 33. Fix all syntax errors and run the program. Was the result what you expected? If not, make ab7App.java 77 // Check if any three cards have the same value the necessary modifications to the threeOfAKind method. Run your = am again. pokerHand.java 78 if ( ( card1. equalValue(card2) && card1.equalValue(card3) ) | | 79 ( card1. equalValue(card2) && card1.equalValue(card4) ) Testing threeOfAKind method: continued ( card1. equalValue(card3) && card1.equalValue(card4)) | | 2 of clubs ( card2. equalValue(card3) && card2.equalValue(card4) ) ) { 82 of clubs 2 of clubs return true; // Return true if three of a kind is found 83 4 of clubs 3 of clubs } else { 5 of clubs 2 of diamonds tem Library [Java: 84 return false; // Return false if no three of a kind is 2 of hearts 85 } Not three of a kind 86 Three of a kind 87 2 of clubs /** 2 of diamonds 3 of clubs 89 * pair method - 2 of hearts 2 of clubs 90 * determines the different ways that a pair that may exist with 4 5 of clubs 2 of diamonds * assumes that four of a kind and three of a kind have already bee Three of a kind 2 of hearts 92 * @return true if a pair exists, false otherwise Three of a kind 93 2 of clubs 94 2 of diamonds 956 public boolean pair() { 3 of clubs 96 // Check if any two cards have the same value 97 if ( (card1. equalValue (card2) ) 2 of hearts Three of a kind Lab#7 - CSC120 - The PokerHand Class 98 ( card1. equalValue(card3) ) 99 (card1. equalValue(card4)) 100 ( card2. equalValue (card3) ) 101 card2. equalValue (card4)) Writable Smart Insert 78...08

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

Students also viewed these Programming questions