Deck of cards programming class

Assignment Help Programming Languages
Reference no: EM13762423

Deck of Cards "Programming Class"

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.

to String:

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

* The output must be taken as a screenshot to show the instructor the output results as it shows in the output.

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: EM13762423

Questions Cloud

Describe the issues that were important in the 2004 : Describe the issues that were important in the 2004, 2008 and 2012 elections, but analyze whether or not there were differences in the way that the candidates campaigned and in the American electorate.
Determine the amount of depreciation expense : Determine the amount of depreciation expense for the years ended December 31, 2006, 2007, 2008, 2009 and 2010 by the following methods:
Write a paper on romeo and juliet : Write a paper on Romeo and Juliet starring Leonardo Diacprio and Claire Danes or the recent version of 'The Tempest' starring Helen Mirren in the traditional male role of Prospero.
Reporting of the securities and exchange commission : Understand the reporting of the Securities and Exchange Commission (SEC) and Sarbanes-Oxley requirements for publically traded companies.
Deck of cards programming class : 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..
Create a detailed erd using the entities and attributes : Create a detailed ERD using the Entities and Attributes for Driver's Log document found on the Huffman Trucking Intranet site. Use Microsoft® Access® to create the preliminary
Set of intellectually incoherent and inconsistent policies : Explain how varied interests and ideologies have conflicted to result in a set of intellectually incoherent and inconsistent policies.
Reporting accuracy-computerized accounting : Imagine you are a consultant hired to convert a manual accounting system to an automated system. Suggest the key advantages and disadvantages of automating a manual accounting system. Identify the most important step in the conversion process. Pro..

Reviews

Write a Review

Programming Languages Questions & Answers

  Procedure to draw shape of choice

Write a program with a suitable procedure to draw shape of your choice. Your program must then call the procedure 10 times to draw the shape.

  Create program which lists total points scored

Create program which lists total points scored for each of 30 classrooms. Include invalid input check if a proper room number is not entered.

  Rewrite the code using a select case block

Rewrite the code using a Select Case block and Determine the output displayed in the text box when the button is clicked

  Design bank account class with data members-member functions

Design the Bank Account class with suitable data members and member functions - think of attributes or features of a bank account - think of kind of data (and actions) you require to open account.

  Write recursive boolean method search array for value

Write down the recursive boolean method named isMember. Method must search the array for specified value, and retun true if value is found, or false if value is not foundin array.

  Create unix shell script to input number of hours worked

Create a Unix shell script to input number of hours worked and pay rate and compute the total pay, then the social security amount (assume 5%), then the net pay.

  Write program to caculate value of user-s stock

Write a program which caculates value of user's holding of a particular stock. Program asks for number of shares held, whole ¬dollar portion of price for one share, also the fraction portion.

  Design recursive program to generate random blurbs

A Whoozit is the character 'x' followed by zero or more 'y's. A Whatzit is a 'q' followed by either a 'z' or a 'd', followed by a Whoozit. Design and implement a recursive program that generates random Blurbs in this alien language.

  As part of a jit initiative at bmws motorcycle assembly

as part of a jit initiative at bmws motorcycle assembly plant bmw has reduced the number of engines loaded on each

  Php code to add-delete product using ajax programming

PHP Code to add a new product and delete a existing product Implement AJAX Programming based solutions to write code to add a new product to the database.

  Determine recursive procedure and iterative procedure

Determine the example or recursive procedure and represent it as iterative procedure. Also, select the iterative procedure which you would re-write as recursive.

  Write application that inputs five number

Use a one-dimensional array to solve the following problem: Write an application that inputs five numbers, each of which is between 10 and 100, inclusive.

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