Question: Can I get some help coding this in Java thank you. Instructions: Setting up the project ( 2 points ) Create a new Java project
Can I get some help coding this in Java thank you.



Instructions: Setting up the project ( 2 points ) Create a new Java project called Module02Test. Add a package called m02 and inside this package, a class Module02 that includes a main method. In addition, add the classes Card, UnoCard, and PokerCard. You may want to create enums for this assignment. Feel free to do so! Style | Doc Comments (5 points) Follow style guidelines and best practices as specified in the Style Guide. Pay special attention to the expectations for Doc Comments. Requirements: (42 points) Implement the classes as specified in the following UML Class Diagram and the additional instructions below. No class members should be added, removed, or changed. Important: Avoid code duplication. - Constructor: - Assigns v to value; - Override the method compareTo: - Returns the expected -1 (Less Than), 0 (Equal To), or 1 (Greater Than) result based the toString() results. (You'll likely need to explicitly call toString). Tip: String uses compareTo as well. - Method equals: - Returns a boolean value bases on if the class is the same and if the value is the same. (You should be able to just compare the toString values) Tip: Strings have an equals method too... - Method toString: - It should return a string that includes the type of the card (UnoCard or PokerCard) and the value (e.g. PokerCard: 1) Note: The default implementation from Eclipse does NOT fulfill the requirements - Method play: - if the topCard is equal(s) to this - prints out "l just played a " where the blank is the toString result. - if the topCard is not equal(s) to this - compare the values of the two Cards - For the higher value print "AND THE WINNER IS.... " where the blank is the toString of the higher valued Card. - If the values are equal then print "IT'S A TIE!!" or something. - Method getValue: - Just a getter. return value. Class UnoCard: // 11 out of 42 points - Constructor: - has Card assign value and store c in color (valid color options are: Blue, Yellow, Red, Green - Method play: - You have to determine if the current card is playable based on topCard (parameter) - if topCard is not an UnoCard then - call super class's play and pass topCard - topCard is an UnoCard AND (this.color must equal topCard.color OR this.value must equal topCard.value) - If it works print "Playing " where blank is toString. - Otherwise, print "Drawing 1 " - Method getColor: - Just a getter, return color. - Override the method toString: - Should do the same as Card but add the color at the end (e.g.: UnoCard: 1 Red). Tip: don't rewrite the code for Card's toString. Class PokerCard: // 11 out of 42 points - Constructor: - has Card assign value and store s in suit some final variables... - Method getSuit: - Just a getter. return suit. - Override the method toString: - Should do the same as Card but add the suit to the end (e.g. PokerCard: 14) Tip: don't rewrite the code for Card's toString. Class Module02: // 8 out of 42 points Class Module02 is the test client and it includes the main method. Within the main method do the following: - Create an ArrayList of type Card and initialize it with 10 random UnoCard and 10 random PokerCard: - Create a loop that will: - Randomly determine the value of the card ( 1 - 12 just to be consistent) - Randomly determine the color (for UnoCards) - Randomly determine the suit (for PokerCards) - Create new instance and assign to the ArrayList - Using Collections.shuffle, shuffle your arraylist... do this a few times. Just to be thorough - Print the ArrayList - Using Collections.sort, sort the ArrayList. - Loop through all the elements in the list. For each element do the following: - NOTE: I had to troubleshoot this a bit when I did it just because I didn't get all 20 to show up. You may want to have it print the current slot number just to test it. I don't want to see current number in the final output. - play the card - If it is the first Card (no prior Card to use) just pass the current card as the topCard. - If it's not the first Card then pass the prior card in the ArrayList Note: - If we were to make an entire arraylist of PokerCard such that we had a full deck of 52 cards represented and then we shuffled a few (read: lots) times, then split that ArrayList into 2 ArrayLists... then took the slot 0 ( remove(0) ) PokerCard from both ArrayLists and compared the values of the two cards to determine which card was higher... then added both of those cards and gave them to the ArrayList with the higher card value... That sounds like a game I know... Note: - If we were to make an entire arraylist of PokerCard such that we had a full deck of 52 cards represented and then we shuffled a few (read: lots) times, then split that ArrayList into 2 ArrayLists... then took the slot 0 ( remove(0) ) PokerCard from both ArrayLists and compared the values of the two cards to determine which card was higher... then added both of those cards and gave them to the ArrayList with the higher card value... That sounds like a game I know... Sample Output (Due to Randomness your output will not be the same though the format will be the same): [UnoCard: 7 YELLOW, PokerCard: 1\$, PokerCard: 114, PokerCard: 1, PokerCard: 3\$, UnoCard: 9 RED, UnoCard: 6 BLUE, UnoCard: 6 BLUE, UnoCard: 2 GREEN, PokerCard: 1\$, UnoCard: 12 YELLOW, PokerCard: 10 , UnoCard: 5 BLUE, PokerCard: 64, UnoCard: 8 RED, PokerCard: 3\$, UnoCard: 2 GREEN, UnoCard: 9 RED, PokerCard: 12\$, PokerCard: 5] I just played PokerCard: 10 . I just played PokerCard: 114 AND THE WINNER IS....PokerCard: 12 AND THE WINNER IS....PokerCard: 12 IT'S A TIE!!! I just played PokerCard: 1 AND THE WINNER IS....PokerCard: 3 IT'S A TIE!!! AND THE WINNER IS....PokerCard: 5 AND THE WINNER IS....PokerCard: 6 AND THE WINNER IS.... UnoCard: 12 YELLOW Drawing 1 Playing UnoCard: 2 GREEN Drawing 1 Playing UnoCard: 6 BLUE Playing UnoCard: 6 BLUE Drawing 1 Drawing 1 Playing UnoCard: 9 RED Playing UnoCard: 9 RED
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
