Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Objectives:

1. To practice defining classes using separate compilation.

2. To practice using classes, vectors, and pointers.

3. To gain experience using dynamic memory.

Scenario:  The owners of the most popular Las Vegas casinos were so impressed with your UCLA promotional interactive animated cartoon that they want to hire you to design a bunch of new electronic card games using C++.  Your first task in this project is to help their coding team finish modeling a playing card and a deck of playing cards as C++ objects.

   Directions:

 Create a Win 32 Console Application project called "Hw8" in your solution called "Homework" using Microsoft Visual Studio.  

 1. You are to implement the following Card class.

enum Suit {HEARTS, CLUBS, SPADES, DIAMONDS};

enum Rank {ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING};

 class Card{

   public:

          Card(Rank r, Suit s);

          Rank getRank()const;

          Suit getSuit()const;

          string toString()const;

   private:

    Suit suit;

    Rank rank;

};

 First place the code above in a header file Card.h and make sure it has include guards.  Then define the Card member functions in the implementation file Card.cpp. I provided the definition of Card's toString() member function below to help get you started:

 string Card::toString()const{

     string description = "";

     switch(rank) {

  case ACE:

    description += "Ace";

    break;

  case TWO:

    description += "Two";

    break;

        case THREE:

    description += "Three";

    break;

  case FOUR:

    description += "Four";

    break;

        case FIVE:

    description += "Five";

    break;

  case SIX:

    description += "Six";

    break;

        case SEVEN:

    description += "Seven";

    break;

  case EIGHT:

    description += "Eight";

    break;

  case NINE:

    description += "Nine";

    break;

        case TEN:

    description += "Ten";

    break;

  case JACK:

    description += "Jack";

    break;

  case QUEEN:

    description += "Queen";

    break;

  case KING:

    description += "King";

    break;

  }

   description += " of ";

   switch(suit) { 

  case HEARTS:

    description += "Hearts";

    break;

  case CLUBS:

                description += "Clubs";

    break;

  case SPADES:

    description += "Spades";

    break;

  case DIAMONDS:

                description += "Diamonds";

    break;

  }

  return description;

}

 Be sure to define the other Card member functions in the implementation file also.

 2. You are to implement the following class CardDeck which models a standard deck of 52 playing cards:

 class CardDeck  {

  public:

     CardDeck();   // default constructor

    ~CardDeck();  // destructor

      /* Returns the Card pointer at the back of the vector or NULL if the deck is empty. */

     Card* getTopCard();

      /* Prints each card, one per line, using the Card's toString() member function. 

     */

     void print()const;

      /* Shuffles the deck of cards by swapping two random elements of the deck.  */

  void shuffle();

     private:

      vector deck;

       /* Swaps the contents of the elements of deck at the given   

         indices. */

      void swapCards(int index1, int index2);

};

 Be sure to put the code above in a header file called CardDeck.h with include guards and the appropriate include statements. The definitions of the CardDeck class member functions should go in the implementation file CardDeck.cpp Make sure the implementation file includes the CardDeck header file.

Java, Programming

  • Category:- Java
  • Reference No.:- M9720923
  • Price:- $50

Priced at Now at $50, Verified Solution

Have any Question?


Related Questions in Java

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As