Program implements the functionality of a deck of cards

Assignment Help JAVA Programming
Reference no: EM13758262

Deck of Cards:

Write a complete program using "ECLIPS" that implements the functionality of a deck of cards. In writing your program, use the provided DeckDriver and Card classes shown below. Write your own Deck class so that it works in conjunction with the two given classes. Use anonymous objects where appropriate.

Deck class details:

Use an ArrayList to store Card objects.

Deck constructor:

The Deck constructor should initialize your ArrayList with the 52 cards found in a standard deck. Each card is a Card object. Each Card object contains two instance variables - num and suit. Study the Card class definition below for details.

dealCard:

This method removes the highest-indexed card in the ArrayList and returns it. In general, a method should not do more than what it's supposed to do. Thus, dealCard should not print anything.

toString:

This method returns the deck's contents using the format shown in the output session. In particular, note that toString should insert a newline after every fifth card. Hint: In coming up with a return value, use a String local variable. As you generate card values and newlines, concatenate those items to your local variable using the += operator.

Write your code such that the following classes produce the output shown in the subsequent output.

* DeckDriver.java

* <your name>

*

* This class tests the Deck class.

public class DeckDriver

{

public static void main(String[] args)

{

Deck deck = new Deck();

System.out.println(deck.dealCard());

System.out.println(deck.dealCard());

System.out.println();

System.out.println(deck);

} // end main

} // end DeckDriver class

* Card.java

* <your name>

*

* This class stores a Card's information.

public class Card

{

private int num; // hold a number between 1 and 13

private char suit; // holds 'C' for clubs, 'D' for diamonds,

// 'H' for hearts, 'S' for spades

public Card(int num, char suit)

{

this.num = num;

this.suit = suit;

} // end Card constructor

// Return the card's value in the form of a concatenated

// number and character.

// For example, 1C = ace of clubs, 12H = queen of hearts.

public String toString()

{

return Integer.toString(num) + suit;

}

} // end class Card

Output:

13S

12S

1C 2C 3C 4C 5C

6C 7C 8C 9C 10C

11C 12C 13C 1D 2D

3D 4D 5D 6D 7D

8D 9D 10D 11D 12D

13D 1H 2H 3H 4H

5H 6H 7H 8H 9H

10H 11H 12H 13H 1S

2S 3S 4S 5S 6S

7S 8S 9S 10S 11S

Reference no: EM13758262

Questions Cloud

Consider the types of poor driving habits : Consider the types of poor driving habits that might occur at a traffic light. Make a list of the 10 you consider most likely to happen. Add the category of “other” to that list. Construct a Pareto chart showing the relative frequency of occurrence o..
Wide gap between planned results and actual accomplishments : When a software measure reveals a wide gap between planned results and actual accomplishments and this is discovered late in the project schedule, why does adding more programming and staffing resources usually result in diminished return?
Design a secure authentication technology : Make a list of access points internal and external (remote). Design a secure authentication technology and network security for GFI
Retaining the value of position : Provide analysis showing the net profit from (i) the covered call and (ii) the protective put on the expiration date assuming the stock price has fallen 20%. Which strategy is more effective at retaining the value of your position?
Program implements the functionality of a deck of cards : Write a complete program using "ECLIPS" that implements the functionality of a deck of cards. In writing your program, use the provided DeckDriver and Card classes shown below. Write your own Deck class so that it works in conjunction with the two..
The outpatient center regarding possible bariatric surgery : Previous medical evaluations have not indicated any metabolic diseases, but he says he has high blood pressure, which he tries to control with sodium restriction and sleep apnea. He current works at a catalog telephone center.
Assuming-size of fish population satisfies logistic equation : A biologist stocked a lake with 45 fish and estimated the carrying capacity (the maximal population for the fish of that species in that lake) to be 7,000. The number of fish tripled in the first year. Assuming that the size of the fish population sa..
Create a pivot table for the training data : Create a pivot table for the training data with Online as a column variable, CC as a row variable, and Loan as a secondary row variable - Create two separate pivot tables for the training data.
What forest/domain model should shiv llc implement : What forest/domain model should Shiv LLC implement? What is the domain name? Where should the domain controllers be place? Should RODC be part of the consideration

Reviews

Write a Review

JAVA Programming Questions & Answers

  Program that uses random instead of scanner to play

Write a Java Program that uses Random instead of Scanner to play many rounds of Rock Paper Scissors. The user and computer will each randomly pick one and common rules of winning apply

  Write a java statement to have the object from manage

Write a Java statement to have the object from manage its display area by dividing it into 3 rows which have 4 columns each.

  Program that allows the user to enter an unknown number

Writer a program that allows the user to enter an unknown number of characters, stores those characters in a data structure (a vector) and then prints the values to the screen.

  It should have an if statement

The following are hints given: It should have an if statement. This add method determines what number greater than or less than the other number, than it adds the positive or negative. I think this should be a private method.

  What is the average response time for this system?

A web server receives a request every 50ms and processes web requests every 8 ms. Using queuing theory, 1. What is the average response time for this system?

  Write an application with three labeled text field

Write an application with three labeled text fields,one each for the initial amount of a savings account, the annual interest rate, and the number of years. Add a button "Calculate" and a read-only text area to display the balance of the savings acco..

  Writing a simple gui application using a class called myguic

writing a simple GUI application using a class called MyGuiClass. Your GUI will have a JButton which your program will need to respond to when it is clicked. Describe what you would need to do to setup event handling using a nested inner class. Use J..

  Die class that can hold an integer

Design a die class that can hold an integer from 1 to 6. use the dice class to create a dice game. in this game, the user chooses a number between 2 and 12 inclusive

  Consider an array of integers

Consider an array of integers as below: int[] a = {5, 2, -4, 3, 0, -5, 7, 11, 6, 13} Complete the method named count(int[] a) in the class Count. The method should return the number of positive numbers in the array

  The array at the index method

have an array, how do i remove an entry from the array at the index method?

  Write a generic class called pair that stores two values

Write a generic class called Pair that stores two values of the generic type. It should have a constructor to set them, two methods getfirst()

  Make a row with different string names

How do you make a row with different string names and put a certain amount of space between each one?

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