Build a small card game called switch

Assignment Help JAVA Programming
Reference no: EM131867292

Build a small card game called SWITCH using expendable array and linked list.

Basic Procedures

You must:
- Fill out a readme.txt file with your information (goes in your user folder, an example readme.txt file is provided)
- Have a style (indentation, good variable names, etc.)
- Comment your code well in JavaDoc style (no need to overdo it, just do it well)
- Have code that compiles with the command: javac *.java in your user directory
- Have code that runs with the command: java PlaySwitch

You may:
- Add additional methods and variables, however these methods must be private
You may NOT:
- Delete/change any code in your starter package such as changing class names, etc.
- Make your program part of a package
- Add additional public methods or variables
- Use any built-in Java Collections Framework classes anywhere in your program (e.g. no ArrayList,
LinkedList, HashSet, etc.)
- Use any arrays anywhere in your program (except in the Hand class data field)
- Alter any method signatures defined in this document of the template code
- Add any additional libraries/packages which require downloading from the internet
Setup
- Download the project1.zip and unzip it. This will create a folder section-yourGMUUserName-p1
- Replace "section" with z001, z002, k003, and z004 for the 4 sections respectively.
- Rename the folder replacing yourGMUUserNamewith the first part of your GMU email address/netID.
Example: k003-jkrishn2-p1
- Complete the readme.txt file (an example file is included: exampleReadmeFile.txt)

Topics Covered
Generics, Array Lists, and Linked Lists

Step 0: Overview
You are going to build a small card game called SWITCH using expendable array and linked list. You will be given two abstract classes - Card and Board, from which you will implement the game specific classes - CardSwitchand BoardSwitch. You will also implement an array list-like data structure that keeps track of the cards in a player's hand. This is the Hand class, used to represent a Player and a Deck. The Board class maintains a linked list-like data structure that keeps track of all players in the game and decides the winner of the game.

Step 1: JavaDocs
You are required to complete the JavaDoc comments for ALL classes including the ones you did not implement (except for PlaySwitch). As part of understanding this project, start with writing JavaDoc comments for the classes that are implemented for you: Card, Deck, and Board. Yes, you will be graded on this, and yes, you need to add comments to the methods and instance variables.

Step 2: Implementing and Understanding the Code

There is a total of 7 classes in the project. However, you are only required to implement some of them.

See the project starter package for all the files.

The abstract Card Class (see Card.java)
[code provided: should not be modified except for adding JavaDoc comments]
A card consists of rank and suit. A regular deck of 52 cards contains 13 different ranks and 4 different
suits. Ranks consist of ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, and KING. Suits consist of HEARTS, CLUBS, DIAMONDS, and SPADES. In our design, every card has a point and a priority which should be implemented in its inherited
classes.

The CardSwitchClass (see CardSwitch.java)
Write a class specific to the game SWITCH by extending the abstract class Card. Required methods:
publicCardSwitch(Rank rank, Suit suit)
- Create a card with a given rank and suit
publicintgetPoints()
- Returns an integer according to the point of this card. ACE = 1 point, 2 = 2 points, 3 = 3 points, .
. . , 9 = 9 points, (10, JACK, QUEEN, KING) = 10 points each.
publicboolean equals(Card anotherCard)
- Returns true if the card is of the same rank and suit of another Card
public String toString()
- Return a string representation of the card in the form of (Rank,Suit) with all capital letters and no space. For example: (KING,SPADES) or (EIGHT,HEARTS)

The Hand<T extends Card>Class (see Hand.java)
Hand holds an array of cards that can be expanded. You need to implement the required methods and make sure their big-O value is as required. Required methods:
public Hand()
- Create an empty hand
publicintnumCards()
- Returns the number of cards in hand
public T getCard(int index)
- Returns the card at the given index. Should throw a RuntimeExceptionfor invalid index
public void setCard(int index, T c)
- Place the given card at the given index: this will replace a card that is already at that index. Should throw a RuntimeExceptionfor invalid index
public void addCard(T c)
- Append a card to the end of the hand. Remember to expand the array if it gets full publicintindexOf(T c)
- Return the index of the given card in the hand. If the card is not present, return -1
public T removeCard(int index)
- Remove and return the card at the given index in the hand. Should throw a RuntimeExceptionfor invalid index
publicbooleanremoveCard(T card)
- Remove the first occurrence of the given card from the hand and return true if removal was successful

The Player<T extends Card>Class (see Player.java)
Player is a linked list node class consisting of name, points, hand, and next player. Required methods:
public Player(String name)
- Create a player setting the player's name and initializing points, hand, and the next player public void setNext(Player<T> p)
- Set the next player. i.e., connect the linked list node to its next public Player<T>getNext()
- Get the next player. i.e., get the linked list node connected to the current publicbooleanhasNext()
- Return true if the player has a next player. i.e., if the current linked list node is connected publicintgetPoints()
- Return the player's points. Total points accumulated by a player in SWITCH game is the sum of points of all cards the player currently has in the hand.
public String getName()
- Return name of the player
publicbooleanreceiveCard(T c)
Add a card to the hand and update points accordingly. Return false if the hand already contains the card, otherwise return true. If the user already has the card in hand, do NOT add it and return false.
publicbooleanhasCard(T c)
- Return true if the given card is present in the hand publicbooleanplayCard(T card)
- Remove the given card from the hand and update points accordingly. Return false if the hand does not have the card, otherwise return true
public T playCard(int index)
- Remove and return the card at the given index in the hand. Should throw a RuntimeExceptionfor invalid index
The abstract Board<T extends Card>Class
[code provided: should not be modified except to add JavaDoc comments]
The board keeps track of the deck, current player, and the number of players. A board should be able to add players and maintains a circularly linked list of players. i.e. Player1 à Player2 à Player3 à Player1 for a 3-player board.

The BoardSwitch<T extends Card>Class (see BoardSwitch.java)
Write a class specific to the game SWITCH by extending the abstract class Board. Required methods:
publicBoardSwitch(Deck<T> deck)
- Construct a board with the given deck. Make necessary initializations for other fields of Board public Player<T>getCurrentPlayer()
- Return current player
publicintgetNumPlayers()
- Return the number of players on the board
public Deck<T>getDeck()
- Return board's deck
publicbooleanchangeTurn()
- Change current player to the next player in the circular linked list. Return true if successful

public Player<T>findWinner()

Go through the players on the board and return the player with maximum points. Use the player's name to break the tie (lexicographical order). You can assume the names are unique. publicbooleanaddPlayer(Player<T> p)
- Add the given player to the left of the current player. Don't forget to keep the linked list circular.

See example below:
The Deck<T extends Card>Class (see Deck.java)
[code provided: should not be modified except for adding JavaDoc comments]

A deck consists of a Hand of cards. The Deck class should be able to add cards, shuffle them, deal the next card, and check the number of cards. You will need to perform big-O analysis to all methods listed here except for the constructor.
public Deck()
- Create a deck initializing the set of cards and the card count publicbooleanaddCard(T c)
- Returns false if the deck already has the card. Otherwise, add the card to the deck and update the card count
publicbooleanhasCard(T c)
- Returns true if the deck has the given card
public void shuffle()
- Randomly shuffles the deck
public T dealNextCard()
- Returns false if the deck has no cards. Otherwise, return the last card in the deck, remove it from
the deck and upublicbooleanisEmpty()
- Returns true if the deck is empty. Otherwise returns false
publicintcardCount()
- Returns the number of cards in the deck
public String toString()
- Returns a string consisting of the cards in the deck
The PlaySwitchClass (see PlaySwitch.java)
[code provided: should not be modified. No JavaDoc comments required]

A provided implementation of a simple game with cards. The game follows these steps:

1. Creating a full deck of 52 cards

2. Creates players and adds them to board

3. Deal all cards to users one by one (all players may not receive same number of cards)

4. Switch the first n cards between the players

5. Player with the higher total points of all cards in hand is the winner

Step 3: Big-O
Template given to you in the starter package contains instructions on the REQUIRED Big-O runtime for each method. Your methods should not have a higher Big-O. For class Deck, you are required to present Big-O run time for all methods (as comments within the code) in addition to Javadoc commenting. Again yes, you will be graded on this.

Step 4: Testing
Test cases will not be provided for this project. However, feel free to create test cases by yourselves. In addition, the main methods provided along with the template classes contain useful code to test your code.

You can use command like "java CardSwitch" to run the testing defined in main( ). You could also edit main( ) to perform additional testing. And yes, a part of your grade will be based on automatic grading using test cases that are not provided to you.pdate the car

You only need to assist on hand player and cardswitch classes

Reference no: EM131867292

Questions Cloud

Compare the present and proposed plans : Top management is seriously considering a "no-charge" plan. Compare the present and proposed plans. What are their strong and weak points
What is the probability that exactly one of the five : a. What is the probability that exactly one of the five has celiac disease? b. What is the probability that only the first adult and the fifth adult
Construct a pie graph : For the data in the table below from the 1977 University of New Hampshire Stat. and Biom. 200 class for eye color, construct a pie graph:
Discuss how eliminations will be determined : Discuss in 175 words how eliminations will be determined, and determine what legal issues must be considered.
Build a small card game called switch : Build a small card game called SWITCH using expendable array and linked list - You are required to complete the JavaDoc comments for ALL classes
Compute the labor rate and the labor efficiency variance : Banner Company manufactures flags of various countries. Compute the labor rate variance and the labor efficiency variance
Draw a conclusion using a critical value : Using a significance level of 0.05, test the above hypotheses and draw a conclusion using a critical value (classical method) approach. (show all work).
Discuss the function of education in society : Discuss the Functionalists' arguments for: 1) explaining why there is economic inequality in society, and 2) the function of education in society.
Probability of obtaining a sample mean this large or larger : If a sample of 64 fish yields a mean of 3.4 pounds, what is probability of obtaining a sample mean this large or larger?

Reviews

inf1867292

4/27/2018 5:47:37 AM

Please read this one. Add additional public methods or variables • Use any built-in Java Collections Framework classes anywhere in your program (e.g. no ArrayList, LinkedList, HashSet, etc.) I have not used collection for existing code and I have only put collection for additional information playerswitch class need no modification and all the codes from the other classes must be implemented based on the three classes provided board, card and playerswitch. this class is modified. I run the project in NetBeans. It is a NetBeans project it will not work in eclipse. We have also given you the screenshots

inf1867292

4/27/2018 5:43:33 AM

Your initial requirements were to create codes for hand player and cardswitch classes only. But now you are asking to create all codes from scratch. In the instruction three of the classes are given no need to write code or modify this classes( card, board, and Deck). the classes need modification are boardswitch, cardswitch hand and player. even for this classes the name of the methods provided in the code and it only need implementation to make the it work. i provide the project instruction and ask for help to make it work at the first time and the instructions are clear about which classes need modification and which classes don't it is all in the attached file.

inf1867292

4/27/2018 5:42:11 AM

Hi in the file that I attached the codes I highlighted with different colors are the codes that I wrote and it is wrong don't use it it. I attached it by accident and also for one of the clas I think playswitch class expect to implement circular link list. The code and the constructions are correct clear and straightforward.i was writing my code and and save it at the end of the project instruction which have errors and don't compile.i want the experts to write their own code not to use mine.

inf1867292

4/27/2018 5:41:19 AM

for hand class please do not use any array library or import arraylist from java.util you have to implement it as requested. please do not use java.util import arraylis you have to create it. also give especial attention for boardswitch class and follow instructions provided all the files and different class information provided with in word file attached most of the codes are provided in each class. please make sure it run with test code. thanks for expert team.

len1867292

2/17/2018 3:48:06 AM

i post all the codes that i have been working on most of the classes working fine but i need help on hand player and cardswitch classes Due to the complexity of this assignment, an accompanying grading rubric pdf has been included with this assignment. Please refer to this document for a complete explanation of the grading. Make a backup copy of your user folder! • Remove all test files, jar files, class files, etc. • You should just submit your java files and your readme.txt • Zip your user folder (not just the files) and name the zip “k003-yourGMUUserName- p1.zip” (no other type of archive) where “yourGMUUserName” is your GMU email address / netID. • Submit to blackboard.

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd