CARD GAME (LINKING AND SORTING) DATA STRUCTURES TOPIC(S) Topic Primary Linked lists Sorting Searching Iterators As…

Homework Help Question & Answers

CARD GAME (LINKING AND SORTING) DATA STRUCTURES TOPIC(S) Topic Primary Linked lists Sorting Searching Iterators As…

CARD GAME (LINKING AND SORTING) DATA STRUCTURES TOPIC(S) Topic Primary Linked lists Sorting Searching Iterators As needed Recursion OBJECTIVES Understand linked lists and sorting concepts and the syntax specific to implementing those concepts in Java. PROJECT The final objective of this project is to create a multi-player card game, but you will create your classes in the order given, as specified. (Analogy: you must have a solid foundation before you can build a house). In order to allow creative freedom, some of the details of selecting instance variables and methods for classes are left to the student. However, instructor will provide direction and assistance if they are needed.
CARD UML class Diagram 1. Write a Card class to represent a playing card. Card – face : String – suit : String PILE (OF CARDS) topCard 1. Write a Pile class to represent a general pile of LINED cards (see Figure 1). a. Include instance variables for i. top and bottom cards in the pile ii. Number of cards. below above b. bottomCard As usual, provide i. Constructors ii. accessor and nutetec methods for all instance variables. iii. A toString method in order to be able to test your class. Figure 1 – Illustration of a Pile with 3 linked cards.
Figure 1 – Illustration of a Pile with 3 linked cards. C. Include methods that represent operations on piles of cards that you may need for your game, such as Pile i. Removing and adding cards (to the top? To the bottom? Somewhere in the middle if sorted?) – topCard : Card ii. Shuffling -bottomCard : Card iii. Searching iv. Sorting – nCards : int v. Other? ? d. Other methods may be added later if you determine that they are needed. 1/ Methods ? 2. Test your Pile class methods before you proceed (will save you time and frustration later). DECK AND HAND 1. Extend class Deck from Pile a. Add any instance variables and behavior (methods) that are not already inherited from Pile. For example, you would need to be able to deal cards. b. As usual, provide constructors, accessor and mutator methods for all instance variables, and a toString() method. i. Call super class (Pile) methods to initialize and update instance variables in that class. Please ask if you’re not sure what this means. C. Test your Deck class before you proceed! 2. if you can think of instance variables and methods that you will need that are unique to Hand (not provided already by Pile) then create a Hand class also extended from Pile. As usual, test before you proceed. Once you write a card game class you may determine that these need additional instance variables and methods. 3.
a. -above : Card Include instance variables above and below of type Card to hold references to the cards before and after the card in a chain of cards (see UML class diagram) – below : Card b. As usual, provide i. Constructors ii. gecessor and nutetec methods for all instance variables iii. A testring method for displaying the card. Have it implement comparable (which will require you to write a comparetel method) so it will be easier later to compare cards. private + setAbovel inA : Card) : void + setBelow(inB : Card) : void + RetAbovel) : Card 2. Test your Card class before you proceed! + RetBelowl) : Card + toString(): String a. This usually mean’s “include a main method in your class, with public object creation and method calls.” b. For example, your main might look something like what is shown in the textbox below: + compare Too 1/ other Methods.? public static void main(String[] args) { // create 2 cards Card abexes new Card (“Nine” Hearts”); Card belers new Card (“Nine Diamonds.”); if you copy and paste watch out for the quotes – they’re often different than the quotes in program editors): // connect the 2 cards aboveSusetRelax(below); belownaetAbove (aboxes); Syaten, aut.printin (abexecugetBelow()); Syaten, aut.printin (below getAboxe ()); // best to test all methods
PLAYER 1. Write a Player class. a. Include instance variables related to players, such as i. name and/or ID ii. hand – instance of the Pile class or, if you have it, Hand (extended from Pile). iii. score. b. Include methods related to players. These may also be added later as you write your Game class. 2. Test your Player class before you proceed. GAME 1. Select a multiple-player card came that you’d like to implement that is complex enough to require a. Objects from your Player, Card, Deck/Pile/Hand classes b. Operations provided in your classes, such as shuffling, searching, dealing, determine winex i. Extra Credit: Sorting 2. Write a Game class. a. Include i. An array of type Player ii. A Deck of cards (or more if your game requires it…). b. If needed, include other instance variables related to your type of game, such as i. A discard Pile of cards C. Depending on the game that you are implementing, methods might include i. initialize() to set up for a new game ii. playO to run the game. You have creative freedom to develop additional classes if they would make your implementation cleaner and/or more elegant. 3. 4. Have fun playing your card game! GOOD PROGRAMMING PRACTICES
GOOD PROGRAMMING PRACTICES Classes • Make instance variables private Make methods public and include (almost always) o Constructors o Accessor(s) and Mutated/s) o testrinal method o compare te method for comparing objects (then, for class, implement the comparable interface) o main method to test your class before you proceed. Put very little code here – try to add class-related behavior into the class method
RUBRIC Requirement Card class (with above and below…) Pile class (with topCard, bottomCard, sorting, shuffling…) Deck (extends Pile, includes methods specific to a deck) Hand (extends Pile, includes methods specific to a player’s hand) Player (has a hand) Game (has players, a deck, maybe a discard pile, initialization and play methods, depending on game)
0 0
Add a comment

GET HELP WITH YOUR PAPERS

GET THIS ANSWER FROM EXPERTS NOW

WhatsApp
Hello! Need help with your assignments? We are here
Don`t copy text!